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
laiz [17]
2 years ago
11

in Java programming Design a program that will ask the user to enter the number of regular working hours, the regular hourly pay

rate, the overtime working hours, and the overtime hourly pay rate. The program will then calculate and display the regular gross pay, the overtime gross pay, and the total gross pay.
Computers and Technology
1 answer:
iren2701 [21]2 years ago
8 0

Answer:

In Java:

import java.util.Scanner;

public class Main {

public static void main(String[] args) {

 int regularhour,overtimehour;

 float regularpay,overtimepay;

 Scanner input = new Scanner(System.in);

 

 System.out.print("Regular Hour: ");

 regularhour = input.nextInt();

 

 System.out.print("Overtime Hour: ");

 overtimehour = input.nextInt();

 

 System.out.print("Regular Pay: ");

 regularpay = input.nextFloat();

 

 System.out.print("Overtime Pay: ");

 overtimepay = input.nextFloat();

 

 float regulargross = regularhour * regularpay;

 float overtimegross = overtimehour * overtimepay;

 float totalgross = regulargross + overtimegross;

 

 System.out.println("Regular Gross Pay: "+regulargross);

 System.out.println("Overtime Gross Pay: "+overtimegross);

 System.out.println("Total Gross Pay: "+totalgross);

 

}

}

Explanation:

This line declares regularhour and overtimehour as integer

 int regularhour,overtimehour;

This line declares regularpay and overtimepay as float

 float regularpay,overtimepay;

 Scanner input = new Scanner(System.in);

 

This prompts the user for regular hour

 System.out.print("Regular Hour: ");

This gets the regular hour

 regularhour = input.nextInt();

 

This prompts the user for overtime hour

 System.out.print("Overtime Hour: ");

This gets the overtime hour

 overtimehour = input.nextInt();

 

This prompts the user for regular pay

 System.out.print("Regular Pay: ");

This gets the regular pay

 regularpay = input.nextFloat();

 

This prompts the user for overtime pay

 System.out.print("Overtime Pay: ");

This gets the overtime pay

 overtimepay = input.nextFloat();

 

This calculates the regular gross pay

 float regulargross = regularhour * regularpay;

This calculates the overtime gross pay

 float overtimegross = overtimehour * overtimepay;

This calculates the total gross pay

 float totalgross = regulargross + overtimegross;

 

This prints the regular gross pay

 System.out.println("Regular Gross Pay: "+regulargross);

This prints the overtime gross pay

 System.out.println("Overtime Gross Pay: "+overtimegross);

This prints the total gross pay

 System.out.println("Total Gross Pay: "+totalgross);

You might be interested in
Write another function to convert a value to its word equivalent leveraging the following tuple - o Number = (‘One’, ‘Two’, … ‘N
prohojiy [21]

Answer:

  1. def convertStr(num):
  2.    Number = ("One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine")
  3.    numStr = str(num)
  4.    output = ""
  5.    for x in numStr:
  6.        index = int(x) - 1
  7.        output += Number[index] + " "
  8.    return output
  9. value = 1234
  10. print(convertStr(value))

Explanation:

Firstly, create a function convertStr that take one input number (Line 1).

This function convert the input number to string (Line 3) and then use for-loop to traverse through the individual digit (Line 6). In the loop, get the target index to extract the corresponding digit letter from the Number tuple(Line 7). The target index is always equal to the current digit number - 1. Next, join the extracted digit letter from the tuple to an output string (Line 8) and return it at the end of the function (Line 10).

We test the function using 1234 as argument (Line 12 - 13) and we shall get One Two Three Four

7 0
3 years ago
Higher Order Functions used for simulations of dice rolls. Definition: An n-sided dice function takes no arguments and always re
tiny-mole [99]

Answer:

#include <iostream>

#include <time.h>

#include <string>

using namespace std;

int main(){

srand(time(NULL));

cout<<"Throw dice"<<endl;

int b =0;

int a=0;

a=rand()%6;

b=rand()%6;

for (int i =0;i<1;i++)

{cout<<"dice one: "<<a<<endl;}

for (int i =0;i<1;i++)

{cout<<"dice two: "<<b<<endl;}

if(a>b)

{cout<<"first dice won"<<endl;}

if(b>a)

{cout<<"second dice won"<<endl;}

else{cout<<"they are same"<<endl;

return main();

}

return 0;

}

Explanation:

/*best dice roll game just for you change it as you want but all necessary things are there/*

5 0
2 years ago
Give two separate print statements: one will print your name, the other will print your major. Ensure that both will print on th
Alexus [3.1K]

Answer:

// here is code in java.

// import package

import java.util.*;

// class definition

class Main

{

   // main method of the class

public static void main (String[] args) throws java.lang.Exception

{

   try{

      // print the name

       System.out.print("my name is Sam. ");

       // print the major

       System.out.print("my major is CS.");

   }catch(Exception ex){

       return;}

}

}

Explanation:

In java, System.out.print() will print the statement but didn't go to the next line.If there is another System.out.print(), then it will also print into the same line.So here first the System.out.print() will print the name and second will print the major in the same line.

Output:

my name is Sam. my major is CS.

4 0
3 years ago
Calculate the performance of a processor taking into account stalls due to data cache and instruction cache misses. The data cac
zhuklara [117]

Answer:

- Calculate the additional CPI due to the icache stalls.

- Calculate the additional CPI due to the dcache stalls.  

- Calculate the overall CPI for the machine.

The additional CPI due to icache stalls = Hit Rate * Hit Latency + Miss Rate*  

Miss Penalty = 0.9*2 + 0.1*50 = 1.8 + 5 = 6.8  

The additional CPI due to dcache stalls = 0.92*2 + 0.08*124 = 11.76  

The overall CPI = 0.3*11.76 + 0.7*1.0 + 1.0*6.8 = 11.03 7.  

Explanation:

6 0
3 years ago
Data from RAM may be placed where to free up space? Log file Swap file Word file Print spool file
hjlf

Answer:

Swap file

Explanation:

5 0
3 years ago
Other questions:
  • The Internet of Things (IoT) is a concept with emphasis on machine-to-machine communications to describe a more complex system t
    10·1 answer
  • An email message form includes all of the following main areas except
    11·2 answers
  • "In an artificial neural network, what input values will cause the neuron below to produce an output of 1". Group of answer choi
    12·1 answer
  • A struggle between opposing forces or characters is
    14·1 answer
  • Blank spaces or unseen control characters in a data file are referred to as
    5·2 answers
  • A student is curious about how a Web site appears on his computer screen. On a piece of paper,
    9·1 answer
  • NEED FIVE QUESTIONS ANSWERED!!!
    7·1 answer
  • Find the basic period and basic frequency of the function g(t)=8cos(10πt)+sin(15πt)
    9·1 answer
  • ________________, _______________ and ___________ are what you see when you open Excel
    14·2 answers
  • Convert the following denary numbers into binary using 8-bit register:
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!