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, 22.06.2019 22:00
Competent nonverbal communication involves interacting with others in a manner that is appropriate for which of the following? select all that apply. situation task individuals
Answers: 3
question
Computers and Technology, 24.06.2019 05:50
What all vehicles has tesla inc. created over the years
Answers: 3
question
Computers and Technology, 24.06.2019 11:00
The program below has been generalized to read a user's input value for hourlywage. run the program. notice the user's input value of 10 is used. modify that input value, and run again. generalize the program to get user input values for workhoursperweek and workweeksperyear (change those variables' initializations to 0). run the program. monthsperyear will never change, so define that variable as final. use the standard for naming final variables. ex: final int max_length
Answers: 2
question
Computers and Technology, 24.06.2019 12:00
An npn transistor is correctly biased and turned on if the a. base is negative. b. collector is negative. c. collector is positive with respect to the emitter and negative with respect to the base. d. collector is the most positive lead followed by the base.
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
History, 06.05.2020 03:12
question
Mathematics, 06.05.2020 03:12
Questions on the website: 13722361