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
The video game machines at your local arcade output coupons depending upon how well you play the game. You can redeem 10 coupons
Lilit [14]

Answer:

coupons = int(input("Enter the number of coupons you win: "))

candy_bars = int(coupons / 10)

gumballs = coupons % 10

print("Candy bars: " + str(candy_bars) + ", Gumballs: " + str(gumballs))

Explanation:

*The code is in Python.

Ask the user to enter the number of coupons

Calculate the number of candy bars, divide the coupons by 10 and typecst the result to int

Calculate the number of gumballs, use the modulo to find the remainder

Print the values

3 0
3 years ago
How can I get multiple user inputs in Java ? I want to be able to use it for subtraction, addition,division and multiplication.F
Evgesh-ka [11]
You can do something like this :

Scanner sc = new Scanner(System.in);
int[] nums = new int[4];

for(int i = 0; i < nums.length; i++) {
System.out.println("Enter next number: ");
nums[i] = sc.nextInt();
7 0
2 years ago
Which two statements describe the Functions of a modem
cupoosta [38]

Answer:

A modem is the internal or external device its function is to transfer data over communication lines

modems use two different types of data transmission

synchronous and asynchronous

The functions of modem have changed over years it was first used for telegrams and to transmit data in 1950s.

Modems were used with computers in  1977 for first time to transmit data between computers  firstly it was used for small amount of computers

As modem improves day by day and were able to transmit information fastly between two or more hosts and the internet network slowly spreads

There are four types of modems ,

1 Fax Modems which solely transfer data between fax machines

2 The traditional ISDN modem

3 the Digital Subscribers Line

4 the Cable Modem

Explanation:

3 0
3 years ago
When you are creating a game you plan to sell online and you need to implement art:
Lilit [14]

Answer:

you can download images that the creator has given permission to use freely.

Explanation:

5 0
3 years ago
Read 2 more answers
Also known as the hard disk, the ______ is the primary storage device of a personal computer. You can also buy an external _____
Stolb23 [73]

Another name for hard disk is called; Hard Drive

The external hard disk is called; External Hard drive

<h3>Computer storage devices</h3>

In computers there are different ways of storing information and all could come under the name drives but the primary storage of a computer which is called hard disk is also called hard drive.

Now, the hard drive could be internal or external and so the one to store additional information is called External Hard Drive.

Read more about Computer Storage Devices at; brainly.com/question/19667078

5 0
2 years ago
Other questions:
  • _____ is two or more connected computers.
    8·1 answer
  • Write a statement containing a logical expression that assigns true to the
    13·1 answer
  • The voluntary linkage of computer networks around the world is called the ______.
    7·1 answer
  • In server-side discovery pattern, load balancing and routing of the request to the service instances are taken care of by the se
    9·1 answer
  • Answer the following
    11·1 answer
  • Describe the functions of ALU, resisters, CU, BIU, Cache and FPU.
    7·1 answer
  • Which model represents scenarios thatchange over time?
    8·1 answer
  • the id selector uses the id attribute of an html element to select a specific element give Example ?​
    11·1 answer
  • What are the 6 major forms that Energy can be grouped into?
    10·1 answer
  • Need help with these plss correct answers
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!