(TCOs 4 and 8) Write a program that asks the user to enter hours worked and rate
ID: 3890615 • Letter: #
Question
(TCOs 4 and 8) Write a program that asks the user to enter hours worked and rate of pay for a week.The program should calculate the person’s weekly pay by multiplying the two numbers (note: noovertime). The program should then display the weekly pay amount and one of the followingmessages, based on the criteria shown.
I love this job—If Weekly Pay is at least $2,000
I like this job—If Weekly Pay is at least $500 but not over $2,000
I kind of like this job—If Weekly Pay is below $500
Use structured pseudocode as demonstrated in the lectures for code, ensure that all variables aredeclared, prompt the user for the appropriate input, and display a meaningful output message. Ensurethat the provided weekly pay and hours worked are greater than 0.
Explanation / Answer
JobTest.java
import java.util.Scanner;
public class JobTest {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("Enter the hours worked: ");
int hours = scan.nextInt();
System.out.println("Enter the rate of pay: ");
double rate = scan.nextInt();
double pay = hours * rate;
if(pay >= 2000){
System.out.println("I love this job");
} else if(pay >=500 && pay <2000) {
System.out.println("I like this job");
} else {
System.out.println("I kind of like this job");
}
}
}
Output:
Enter the hours worked:
50
Enter the rate of pay:
35
I like this job
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.