1.
Create a file called
Die.java
, with an empty class in it.
2.
Add a new (private) field to the class to store the number of sides. You probably want this to
be an
int
.
3.
Create
a
constructor
for
Die
that
takes
one
argument,
an
int
representing
the
number
of
sides.
If the number is less than 2, store 6 as the number of sides in the class field.
Other-
wise, store the number given.
4.
Create a no-argument constructor.
It should assume the number of sides is six.
You can do
this in one line with the
this()
constructor, but that isn’t required to get full credit.
5.
Add a
roll()
method to your
Die
, which takes no arguments and returns an
int
between 1
and the number of sides (inclusive).
Create
a
constructor
for
Die( singular dice as in one)
that
takes
one
argument,
an
int
representing
the
number
of
sides.
If the number is less than 2, store 6 as the number of sides in the class field.
Other-
wise, store the number given.
A certain mobile phone company charges its customers using per second billing. The tariff used is post paid. The following rules are used in the billing procedure.
Required
Write an object oriented Java program that can be used by the company to bill its customers.
Write a simple payroll program that will display the employee’s information. The program should perform
the following:
Solution in java ONLY plz... FULL question can be found on the following link http://ntci.on.ca/compsci/java/ch6/6_10.html ---> question 7
I cannot put full question here as its too long... so full question is on the link
The requirement is for it to NOT be done with import java.io.*; etc..... just directly
Thanks, appreciate it
----------------------------------------------------------------------------------
Write a class Lock that could be used to create electronic lock objects. Each lock may be in either an open (unlocked) or a closed (locked) state and each one is protected by its own integer key which must be used to unlock it. The class should contain the following methods.
create method
parameters: string array and integer variable
return: integer variable max
method will receive a string array containing scores for a single day and return the id of the player with maximum score
For a day “12,0-234,1-23,3-201,2-1”. The array would be arr [0] is a string “12”
arr [1] is“0-234”arr [2] is“1-23”arr [3] is“3-201” arr [4] is“2-1”
assume ply.txt file is used
While the first element is game points for that day, other elements are player id and their score for the day.Using a loop,we need to process each players score.We will extract the player id and their score (string indexOf, substring and Integer.parseInt). After finding it, it should place the score for player in a temporary array for players. Then it should find the id of player with highest scores.
For this, create a temporary array Scores and store score of player 0 in Scores[0], score of player 1 in Score[1] and so on.
This method will return max as the id of the playerwith highest score for the data of day in inputarray arr.
Using WHILE LOOP
Write a Program that will ask the user to accept an
integer input and outputs message below:
Choose what you want to print:
1. Print Hello Philippines
2. Print Numbers Ascending (from 1)
3. Print Numbers Descending (from 1000)
Enter the number that you want to print:
Number of iterations:
IT is useful for implementing a firm's corporate social responsibility (CSR). Discuss two ways the IT profession can contribute to CSR.
The file dictionary.txt is a "dictionary" file containing a long list of words. Write a Java program to report the following information:
a. the number of words in the file,
b. the average number of letters per word,
c. the longest word and its length (if there is more than one word of greatest length, you only need to report one of them),
d. the shortest word and its length (if there is more than one word of least length, you only need to report one of them),
e. the first word in the file,
f. and the last word in the file.
A point on the two-dimensional plane can be represented by two numbers: a X coordinate and a Y coordinate. For example, (4,5) represents a point 4 units to the right of the origin along the X axis and 5 units up the Y axis. The sum of two points can be defined as a new point whose X coordinate is the sum of the X coordinates of the points and whose Y coordinate is the sum of their Y coordinates.
Write a program that uses class point to model a point. Define data members X and Y coordinates. Create objects for point class, get data from user for two points, pass it using constructors. Use data member function SumPoint(obj1, obj2) to find the sum and return it. Use another member function Display() to display the new coordinates.