Question: Can someone help me edit my program to meet the following ? 1. Using a switch statement: If the employee type is P or p,
Can someone help me edit my program to meet the following ?
1. Using a switch statement:
If the employee type is P or p, then display "part- time employee" on the screen [1 point]
If the employee type is F or f, then display "full-time employee" on the screen [1 point]
If the employee type is T or t, then display "temporary employee" on the screen [1 point]
If the employee is none of the above, then display "unknown employee type" on the screen [1 point]
2. Using if-else or an if-else-if statement:
If the total hours worked is less than 0 or greater than 280, then print out "That's not possible!" to the screen [2 points]
If the pay rate is greater than or equal to $100, then print out "You must be a Java programmer" [1 point]
import java.util.Scanner;
public class CalculatePay {
public static void main(String args[]){
Scanner scanner=new Scanner(System.in);
System.out.println("What is your name?");
String name = scanner.nextLine();
System.out.println("How many hours did you work?");
int hoursWorked = scanner.nextInt();
System.out.println("What is your pay rate?");
float payRate=scanner.nextFloat();
System.out.println("What type of employee are you?");
char employeeType=scanner.next().charAt(0);
//Calculating total pay
float totalPay=hoursWorked*payRate;
//Displaying the final string that includes 2 variables
System.out.printf("Hi %s , you made $%.2f this week !", name, totalPay); //printout our string (name) //2 digits after the decimal
}
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
