Professional Documents
Culture Documents
Acitivity 2 CC203
Acitivity 2 CC203
Activity 2
Instructions:
The filename of this activity is Activity2 – (Complete name). Then save this activity on the
Google Drive. Place your code at the end of these problem.
Problem 1:
Consider the following program segment:
//import classes
public class Exercise4
{
}
public static void main(String[] args)
{
//variable declaration
//executable statements
}
j. Write Java statements that prompt the user to enter a decimal number between 0
and 70 and then store the number entered into hoursWorked.
k. Write a Java statement that multiplies that value of the named constant RATE with
the value of hoursWorked and stores the result into the variable wages.
l. Write Java statements that produce the following output:
Name: //output the value of the variable name
Pay Rate: P //output the value of the named constant RATE
Hours Worked: //output the value of the variable hoursWorked
Salary: P //output the value of the variable wages
m. For example, if the value of name is "Rainbow" and hoursWorked is 45.50, then the
output is:
Name: Rainbow
Pay Rate: P 12.50
Hours Worked: 45.50
Salary: P 568.75
Problem 2:
Write a program that prompts the user to input a decimal number and outputs the number
rounded to the nearest integer.
Problem 3:
A milk carton can hold 3.78 liters of milk. Each morning, a dairy farm ships cartons of milk
to a local grocery store. The cost of producing one liter of milk is P150, and the profit of each
carton of milk is P560.00. Write a program that does the following:
a. Prompts the user to enter the total amount of milk produced in the morning
b. Outputs the number of milk cartons needed to hold milk (Round your answer to the nearest
integer.)
c. Outputs the cost of producing milk
d. Outputs the profit for producing milk
e. Redo Programming Exercise 14 so that the user can also input the cost of producing one
liter of milk and the profit on each carton of milk.