subject

The following program uses a variable workHoursPerWeek rather than directly using 40 in the salary calculation expression.

Run the program, observe the output. Change 40 to 35 (France's work week), and run again.

Generalize the program further by using a variable workWeeksPerYear. Run the program. Change 50 to 52, and run again.

Introduce a variable monthlySalary, used similarly to annualSalary, to further improve program readability.

public class Salary {
public static void main (String [] args) {
int hourlyWage = 20;
int workHoursPerWeek = 40;
// FIXME: Define and initialize variable workWeeksPerYear, then replace the 50's below
int annualSalary = 0;

annualSalary = hourlyWage * workHoursPerWeek * 50;
System. out. print("Annual salary is: ");
System. out. println(annualSalary);

System. out. print("Monthly salary is: ");
System. out. println((hourlyWage * workHoursPerWeek * 50) / 12);

return;
}
}

ansver
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 21:00, bryanatwin1536
Describir textbook icon_person mira los dibujos y describe lo que está pasando. usa los verbos de la lista.
Answers: 1
image
Computers and Technology, 23.06.2019 21:20, FlowerChild1229
For positive constants a and b, the force between two atoms in a molecule is given f(r) = −a r2 + b r3 , where r > 0 is the distance between the atoms. note: a and b are upper case letters. (a) find f '(r) = (b) find the critical point for f(r). r = (c) find f ''(r) = (d) find the value of r so that f ''(r) = 0.
Answers: 1
image
Computers and Technology, 24.06.2019 12:00, yagalneedshelp8338
Match the function to its purpose. fast worth 50pts.
Answers: 1
image
Computers and Technology, 24.06.2019 13:00, giulissaf
Append and make table queries are called queries. select complex simple action i think action
Answers: 1
You know the right answer?
The following program uses a variable workHoursPerWeek rather than directly using 40 in the salary c...

Questions in other subjects:

Konu
Social Studies, 17.07.2019 05:00