Answer:
<u> Initial program output (from original program)</u>
Annual salary is: 40000
Monthly salary is: 3333
<u>Program output after workHoursPerWeek = 35</u>
Annual salary is: 35000
Monthly salary is: 2916
<u>Revised program (using variable workWeeksPerYear)</u>
- public static void main(String[] args) {
-
- int hourlyWage = 20;
- int workHoursPerWeek = 35;
- int workWeeksPerYear = 52;
- int annualSalary = 0;
-
- annualSalary = hourlyWage * workHoursPerWeek * workWeeksPerYear;
- System.out.print("Annual salary is: ");
- System.out.println(annualSalary);
-
- System.out.print("Monthly salary is: ");
- System.out.println((hourlyWage * workHoursPerWeek * workWeeksPerYear) / 12);
-
- return;
-
- }
Program output:
Annual salary is: 36400
Monthly salary is: 3033
<u>Revised Program after introducing monthly salary</u>
- public static void main(String[] args) {
-
- int hourlyWage = 20;
- int workHoursPerWeek = 35;
-
- int workWeeksPerYear = 52;
- int annualSalary = 0;
- int monthlySalary = 0;
-
- annualSalary = hourlyWage * workHoursPerWeek * workWeeksPerYear;
- monthlySalary = hourlyWage * workHoursPerWeek * workWeeksPerYear;
-
- System.out.print("Annual salary is: ");
- System.out.println(annualSalary);
-
- System.out.print("Monthly salary is: ");
- System.out.println((monthlySalary) / 12);
-
- return;
-
- }
Explanation:
One reason to use variable to replace the magic number is to improve the readability of the program. If we compared the revised version of the program with the original program, we will find that the variable enable our code easier to understand.
Besides, if we wish to change the value (e.g. working hours per year or per month), we just need to adjust the value assigned on the variables. The variables provide a single access point to get or change the value.
An Object Class. Hopefully this answer is right.
Output device - keyboard
Input device- mouse
Answer:
1. Start
2. Display "Enter three numbers"
3. Input A
4. Input B
5. Input C
6. Sum = A + B + C
7. Display Sum
8. Stop
Explanation:
Line 1 and Line 7 of the algorithm implies the start and end of the algorithm, respectively.
Line 2 prompts user for input of three numbers
Line 3 to 5 accept input from user and these inputs are saved in variables A, B and C
Line 6 adds the three inputs and saves the result in variable Sum
Line 7 displays the value of Sum
Answer:
Change default username and password.
Explanation:
The corporation under which Derek works has assigned him an assignment of establishing and safeguarding a SOHO router. He intends to ensure that maybe the wireless connection is protected and no further unauthorized person would connect the device to the router. So, the first task is to simply change the username and password that the wifi routers will be secured.
So, the following answer is correct about the given scenario.