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
If you paste a word document text into an excel spreadsheet, the paste optio allow you to keep source formatting or
castortr0y [4]
I think the answer is c
6 0
3 years ago
Write a Scheme function called "sum" which takes an input function func and a nonnegative number n and outputs the value
solong [7]

Answer:

function sum(number) {

      if (number == 1) {

             return 1;

      }

      return number + sum(number -1);

}

Explanation:

This is a recursive function, it means that is a function that calls itself for example: if you call the function with sum(5) the process is :

sum(5)

   |______ 5 + sum(4)

                           |_______ 4 + sum(3)

                                                       |______ 3 + sum(2)

                                                                                   |_____2 + sum(1)

                                                                                                        |_____ 1

                                                                                                 

the result is 1+2+3+4+5 = 15

7 0
3 years ago
A technique for identifying and tracking assets using technologies such as RFID and smart cards is known as electronic tagging.
Mademuasel [1]

Answer: True

Explanation: Electronic tagging is defined as the activity in which the monitoring of the things and people are done through the electronic markers or device .This process is usually done by attaching a tag sized component on the ankle of the human to monitor them.

The tracking of the good and human is done by production of the time alerts through the tag .Thus the statement given in the question is true.

4 0
3 years ago
Why would an online survey of 2,000 visitors to your college’s Web site be of little use in assessing the neighboring community’
musickatia [10]

Answer: the sample is not representative of the community.

Explanation:

Online surveys or surveys in general are made to obtain relevant information about a particular issue. If samples are not representative of that issue, they end up having little use.  

4 0
4 years ago
Walt has selected data in a worksheet and inserted a chart. However, the chart is inserted right on top of the data set, and he
Marianna [84]

Answer:

Click View and zoom into the worksheet so the chart is easily visible.

Explanation:

5 0
3 years ago
Read 2 more answers
Other questions:
  • Choose the sentences that describe techniques of formatting text.
    12·1 answer
  • Write a program that asks the user for three strings. Then, print out whether the first string concatenated to the second string
    8·1 answer
  • Having friends who cause you stress can decrease your happiness, which can in turn
    13·2 answers
  • Create html code showing heading tags​
    6·1 answer
  • What layer of the OSI model describes how data between applications is synced and recovered if messages don't arrive intact at t
    12·1 answer
  • Después de un incidente de seguridad del cliente, el equipo realiza un análisis en profundidad de cada paso dado por los atacant
    6·1 answer
  • One benefit of taking notes in class is that the student
    9·1 answer
  • Write the features of Mark-I.​
    7·1 answer
  • Write a boolean expression that is true if s references the string end.
    8·1 answer
  • 9- Write a program in MARIE to add three numbers.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!