Professional Documents
Culture Documents
JAVA WORKSHEET HW
1) Write a JAVA program that performs the following:
Ask a user to enter a number.
• If the number is between 0 and 10, write the word blue.
• If the number is between 10 and 20, write the word red.
• If the number is between 20 and 30, write the word green.
• If it is any other number, write that it is not a correct color option.
2) Horses are entered for a horse race. A horse may have to carry a penalty
weight in addition to the rider. This weight is added to the saddle. The penalty
weight (if any) depends on the number of wins the horse has achieved in
previous races.
The penalty weight is calculated as follows:
0 0
1 or 24 4
Over 28 8
5) Write a java class to calculate and print the electricity bill to be paid by a
customer. Assume that the customer pays a rent of Rs. 250.00 .
No. of units Charge per unit
Upto 100 units Rs. 1.50
For the next 100 units Rs. 2.00
For next 50 units Rs. 2.50
Beyond 250 units Rs. 4.00