Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Calculate salary: Generalize a program with variables and input.(JavaScript) The program below has been generalized to read a user's input value for hourlyWage. Run the

Calculate salary: Generalize a program with variables and input.(JavaScript)

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 = 99. Run the program.

Change the values in the input area below the program, and run the program again.

import java.util.Scanner;

public class Salary { public static void main (String [] args) { Scanner scnr = new Scanner(System.in); int hourlyWage = 0; int workHoursPerWeek = 40; int workWeeksPerYear = 50; int monthsPerYear = 12; // FIXME: Define as final and use standard naming int annualSalary = 0; int monthlySalary = 0; System.out.println("Enter hourly wage: "); hourlyWage = scnr.nextInt();

// FIXME: Get user input values for workHoursPerWeek and workWeeksPerYear

annualSalary = hourlyWage * workHoursPerWeek * workWeeksPerYear; System.out.print("Annual salary is: "); System.out.println(annualSalary); // FIXME: Change monthsPerYear to the final variable that uses the standard naming monthlySalary = (hourlyWage * workHoursPerWeek * workWeeksPerYear) / monthsPerYear; System.out.print("Monthly salary is: "); System.out.println(monthlySalary);

return; } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications Dexa 2023 Workshops 34th International Conference Dexa 2023 Penang Malaysia August 28 30 2023 Proceedings

Authors: Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil ,Bernhard Moser ,Atif Mashkoor ,Johannes Sametinger ,Maqbool Khan

1st Edition

303139688X, 978-3031396885

More Books

Students also viewed these Databases questions