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

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 04:31
Q13 what function does a security certificate perform? a. creates user accounts b. scrambles data c. identifies users d. creates password policies e. provides file access
Answers: 1
question
Computers and Technology, 23.06.2019 09:30
Which of the following tasks is an audio technician most likely to perform while working on a nature documentary? (select all that apply). eliminating potentially distracting background noise adding sound effects making sure the lighting is adequate for a particular scene changing the narration to better match the mood of the documentary
Answers: 3
question
Computers and Technology, 23.06.2019 17:00
The more powerful, 60 volt cables and the main power shut off on an hev are both colored orange
Answers: 1
question
Computers and Technology, 23.06.2019 21:00
Alcohol’s affects on the cornea and lens of the eye make it more difficult
Answers: 1
You know the right answer?
The following program uses a variable workHoursPerWeek rather than directly using 40 in the salary c...
Questions
question
English, 19.09.2020 01:01
question
French, 19.09.2020 01:01
question
Physics, 19.09.2020 01:01
question
Chemistry, 19.09.2020 01:01
Questions on the website: 13722361