I needv pseudocode and a flowchart for the following java code public class AcmePay { public static void...

90.2K

Verified Solution

Question

Programming

I needv pseudocode and a flowchart for the following javacode

public class AcmePay {
public static void main(String[] args) throws Exception {

Scanner scanner = new Scanner(System.in);
int hours, shift, retirement = 0;
do {


System.out.print(\"Enter the number of hours worked (>0):\");
hours = scanner.nextInt();
} while (hours <= 0);

do {

System.out.print(\"Enter shift [1 2 or 3]: \");
shift = scanner.nextInt();
} while (shift < 1 || shift > 3);

if (shift == 2 || shift == 3) {
do {

System.out.print(\"Elect for retirement plan (1 for yes, 2 forno): \");
retirement = scanner.nextInt();
} while (retirement < 1 || retirement > 2);
}


compute(hours, shift, retirement);


}

private static void compute(int hours, int shift, intretirement) {

System.out.println(\"Hours Worked: \" + hours);
double regularPay = 0, overtimePay = 0, total = 0, deduction = 0,netPay = 0;
if (shift == 1) {
System.out.println(\"Shift: First Shift\");
if (hours <= 40) {
regularPay = hours * 17;
overtimePay = 0;
} else {
regularPay = 40 * 17;
overtimePay = (hours - 40) * 17 * 1.5;
}
total = regularPay + overtimePay;

} else if (shift == 2) {
System.out.println(\"Shift: Second Shift\");
if (hours <= 40) {
regularPay = hours * 18.5;
overtimePay = 0;
} else {
regularPay = 40 * 18.5;
overtimePay = (hours - 40) * 18.5 * 1.5;
}
total = regularPay + overtimePay;
if (retirement == 1) {
deduction = 0.03 * total;
netPay = total - deduction;
}

} else if (shift == 3) {
System.out.println(\"Shift: Third Shift\");
if (hours <= 40) {
regularPay = hours * 22;
overtimePay = 0;
} else {
regularPay = 40 * 22;
overtimePay = (hours - 40) * 22 * 1.5;
}
total = regularPay + overtimePay;
if (retirement == 1) {
deduction = 0.03 * total;
netPay = total - deduction;
}
}

System.out.printf(\"Regular Pay : $%10.2f\n\", regularPay);
System.out.printf(\"Overtime Pay : $%10.2f\n\", overtimePay);
System.out.printf(\"Total Pay : $%10.2f\n\", total);
System.out.printf(\"Deduction : $%10.2f\n\", deduction);
System.out.printf(\"Net Pay : $%10.2f\n\", netPay);


}
}

Answer & Explanation Solved by verified expert
3.9 Ratings (592 Votes)
PseudoCode as Follows 1 Ask user to enter number of hours he worked 2 If the value he entered is less than 0 as that makes nosense Go Back to 1 until he enters valid hoursIf the value enter is valid Store it in Hours variable3 Ask user to enter shift number 4 If the value he entered is less than 1 or greater than 3 asthat makes no sense Go Back to 3 until he enters valid    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students