1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Reika [66]
3 years ago
7

Write a programm that has been generalized to read a user's input value for hourlyWage.Generalize the program to get user input

values for workHoursPerWeek and workWeeksPerYear (change those variables' initializations to 0).

Computers and Technology
1 answer:
Nina [5.8K]3 years ago
6 0

Answer:

The simple way to get user input values is:

in C++:

Suppose hourlyWage, workHoursPerWeek and workWeeksPerYear are int type variable. So first declare and initialize these variables to 0

int workHoursPerWeek = 0;

int workWeeksPerYear = 0;

int hourlyWage = 0;

Now a print statement can be used to prompt user to enter the values for hourlyWage, workHoursPerWeek and workWeeksPerYear as:

cout<<"Enter hourly wage: ";

cout<<"Enter work hours per week: ";

cout<<"Enter work hours per year:  ";

Next, to read the user input value cin statement is used which reads the values for the above variables as:

cin>>hourlyWage;

cin>>workHoursPerWeek;

cin>>workWeeksPerYear;

In JAVA:

First declare the three variables and initialize the variables to 0:

int hourlyWage = 0;

int workHoursPerWeek = 0;

int workWeeksPerYear = 0;

Next, prompt the user to enter the values for these variables and read the input values. We use Scanner class to take input from user.

Scanner scnr = new Scanner(System.in);  //creates an object of Scanner class named scnr

System.out.println("Enter hourly wage: ");  //prompts user to enter the value for hourly wage

hourlyWage = scnr.nextInt();  //reads the value of hourly wage from user

System.out.println("Enter work hours per week: "); //prompts user to enter the value for work hours per week

workHoursPerWeek = scnr.nextInt();  //reads the value of work hours per week from user

System.out.println("Enter work hours per year: "); //prompts user to enter the value  for work hours per year

workWeeksPerYear = scnr.nextInt(); //reads the value of work hours per year from user

Explanation:

Here is the complete JAVA program:

import java.util.Scanner;  // used to take input from user

public class Salary {    

public static void main (String [] args) {  //start of main function

Scanner scnr = new Scanner(System.in); //creates object of Scanner class

//declare and initialize variables

int hourlyWage = 0;  

int workHoursPerWeek = 0;

int workWeeksPerYear = 0;

final int monthsPerYear = 12;  //Declares as final and use standard naming

int annualSalary = 0;

int monthlySalary = 0;

/*prompts user to enter the value for hourly wage, work hours per week and work hours per year and reads the values from user. nextInt() is used to scan the next token of the input as a Int */

System.out.println("Enter hourly wage: ");

hourlyWage = scnr.nextInt();

System.out.println("Enter work hours per week: ");

workHoursPerWeek = scnr.nextInt();

System.out.println("Enter work hours per year: ");

workWeeksPerYear = scnr.nextInt();  

annualSalary = hourlyWage * workHoursPerWeek * workWeeksPerYear;  //computes annual salary

System.out.print("Annual salary is: ");    

System.out.println(annualSalary);    //displays annual salary

monthlySalary = (hourlyWage * workHoursPerWeek * workWeeksPerYear) / monthsPerYear;  //computes monthly salary

System.out.print("Monthly salary is: ");  

System.out.println(monthlySalary);   //displays value of monthly salary

return;  }  }

The output and program screenshots are attached.

You might be interested in
When a number gets assigned to a variable that already has a value __________?
Aleksandr-060686 [28]
A already assigned variable cannot be assigned twice You can make the variable change over to a new one or call a whole new one to assign one without a value or It might be possible to do v=n (v is variable and n is number / value)
3 0
3 years ago
Which option is used in emails to inform the recipient that they should exercise discretion in accordance with sharing the conte
Kay [80]
Priority levels hehe good luck!
5 0
3 years ago
When two or more people come together to communicate, each person brings their own ___________________.
dimulka [17.4K]

When two people come together,  each with a clear definition of their  identities, the potential can be astounding.  A successful communication is composed of two  individuals - each with a clearly defined sense  of her or his own identity.  

6 0
3 years ago
Sketch a 2K x 32 memory built from 1K x 8 memory chips. Include control, address, and data line details, as well as any decoding
Scrat [10]

Answer:

See my explanations and attachment

Explanation:

Construct an 8k X 32 ROM using 2k X 8 ROM chips and any additional required components. Show how the address and data lines of the constructed 8k X 32 ROM are connected to the 2k X 8 chips.

I tried to solve it but I am not sure if I got the correct answer. Could anyone check my drawing and correct me?

8 0
4 years ago
What do we call the two parts of lift that goes down a mine
Blababa [14]
The sheave wheel is a pulley wheel that sits above the mine shaft. The hoist cable passes over the sheave wheel and then down the shaft of the mine.
(copied from google)
4 0
3 years ago
Read 2 more answers
Other questions:
  • On the Picture Tools Layout tab, you can preview results of the numerous styles, borders, effects, and layouts by _______ comman
    7·2 answers
  • I don’t know technically
    9·2 answers
  • 52.
    11·1 answer
  • An advertisement for new headphones lists the cool colors available, the great sound quality, and the fabulous reviews but fails
    14·1 answer
  • When a defendant pleads guilty to one offense just to have another offense dropped, this is what type of plea bargain
    12·2 answers
  • Tamara has $500 she is looking to save for a class trip. She wants to earn the most possible interest and will not need access t
    7·1 answer
  • Which do web servers host?<br> Websites<br> Networks<br> Firewalls<br> Zones
    8·1 answer
  • History timeline: who developed what elements first Windows OS and Apple OS?
    13·2 answers
  • Which of the following should you consider when choosing a file format?
    9·2 answers
  • What is a guardian node summary for theta staking tool
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!