Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please edit the Java program below so that the following requirements are met an

ID: 3860704 • Letter: P

Question

Please edit the Java program below so that the following requirements are met and the program should repeatedly execute until the user enters 0. I use jGrasp for this program also a screenshot of the program in jGrasp would be helpful.

A home service company offers three types of service: regular service, weekend service, and emergency service. The hourly rates are shown below.

Service Number: Service: Hourly Rate:

1 Regular Service $55.99

2 Weekend Service $75.99

3 Emergency Service $99.99

Write a program that reads a series of pairs of numbers as follows:

a) Service number

b) Hours spent

And then the program displays the cost before taxes.

The program should be menu driven, giving the user various choices:

1 --- Regular Service ($55.99/hour)

2 --- Weekend Service ($75.99/hour)

3 --- Emergency Service ($99.99/hour)

0 --- Exit

You should use a flag-controlled or a sentinel-controlled while loop so that the program can get a series of sales data until the user enters 0. Inside the loop, a switch structure is used to help select a service and outputs the cost for each service.

Your program should also calculate and output the total cost of each type of service provided, and calculate and output the overall value of all services provided.

import java.util.Scanner;

public class Service
{


public static void main(String[]args)
{

Scanner console=new Scanner(System.in);
  

int Menu;
double job1, job2, job3;
double hour, total;

  
System.out.print(" Welcome to Services" +
" *******************************************" +
" Enter 1, 2, 3 to start or 0 to exit Services." +
" " +
" 1 -- Regular service $55.99/hour" +
" 2 -- Weekend Service $75.99/hour" +
" 3 -- Emergency Service $99.99/hour" +
" 0 -- Exit" );

System.out.println( " Select service" );
Menu = console.nextInt();
total = 0;

if (Menu==1 )
{
  
System.out.println(" This is option 1 for $55.99 an hour."+
" How many hours?: " );
hour = console.nextDouble();

while( hour<0 ){
System.out.println(" Error: number of hours is incorrect");
hour = console.nextDouble();   
}
  
job1 = 55.99 * hour;
System.out.print(" The cost is " + "$" + job1 + " before tax.");
total = total+job1;
  
System.out.print(" Price of services: $" +total);
}
  
if (Menu==2 )
{
  
System.out.println(" This is option 2 for $75.99 an hour."+
" How many hours?: " );
hour = console.nextDouble();
  

while( hour<0 )
{
System.out.println(" Error: number of hours is incorrect");
hour = console.nextDouble();
}
  
job2 = 75.99 * hour;
System.out.print(" The cost of this service is " + "$" + job2 + " before tax.");
total = total + job2;
  
  
System.out.print(" Price of services provided: $" +total);
}

if (Menu==3 )
{
System.out.println(" This is option 3 for $99.99 an hour."+
" How many hours?: " );
hour = console.nextDouble();

while( hour<0 )
{
System.out.println(" Error: number of hours is incorrect");
hour = console.nextDouble();   
}
  
job3 = 99.99 * hour;
System.out.print(" The cost is " + "$" + job3 + " before tax.");
total= total+job3;
  
  
System.out.print(" Price of services: $" +total);
}
  
  
}// end main

}// end class

Explanation / Answer

Hi

I have updated the code and highlighted the code changes below

Service.java

import java.util.Scanner;
public class Service
{

public static void main(String[]args)
{

Scanner console=new Scanner(System.in);
  

int Menu = -1;
double job1, job2, job3;
double hour, total;

while(Menu != 0){
System.out.print(" Welcome to Services" +
" *******************************************" +
" Enter 1, 2, 3 to start or 0 to exit Services." +
" " +
" 1 -- Regular service $55.99/hour" +
" 2 -- Weekend Service $75.99/hour" +
" 3 -- Emergency Service $99.99/hour" +
" 0 -- Exit" );

System.out.println( " Select service" );
Menu = console.nextInt();
total = 0;
if(Menu != 0) {
if (Menu==1 )
{
  
System.out.println(" This is option 1 for $55.99 an hour."+
" How many hours?: " );
hour = console.nextDouble();

while( hour<0 ){
System.out.println(" Error: number of hours is incorrect");
hour = console.nextDouble();   
}
  
job1 = 55.99 * hour;
System.out.print(" The cost is " + "$" + job1 + " before tax.");
total = total+job1;
  
System.out.print(" Price of services: $" +total);
}
  
if (Menu==2 )
{
  
System.out.println(" This is option 2 for $75.99 an hour."+
" How many hours?: " );
hour = console.nextDouble();
  

while( hour<0 )
{
System.out.println(" Error: number of hours is incorrect");
hour = console.nextDouble();
}
  
job2 = 75.99 * hour;
System.out.print(" The cost of this service is " + "$" + job2 + " before tax.");
total = total + job2;
  
  
System.out.print(" Price of services provided: $" +total);
}

if (Menu==3 )
{
System.out.println(" This is option 3 for $99.99 an hour."+
" How many hours?: " );
hour = console.nextDouble();

while( hour<0 )
{
System.out.println(" Error: number of hours is incorrect");
hour = console.nextDouble();   
}
  
job3 = 99.99 * hour;
System.out.print(" The cost is " + "$" + job3 + " before tax.");
total= total+job3;
  
  
System.out.print(" Price of services: $" +total);
}
}
}

  
}// end main

}// end class

Output:


Welcome to Services
*******************************************
Enter 1, 2, 3 to start or 0 to exit Services.

1 -- Regular service $55.99/hour
2 -- Weekend Service $75.99/hour
3 -- Emergency Service $99.99/hour
0 -- Exit
Select service
1

This is option 1 for $55.99 an hour.
How many hours?:
2

The cost is $111.98 before tax.
Price of services: $111.98
Welcome to Services
*******************************************
Enter 1, 2, 3 to start or 0 to exit Services.

1 -- Regular service $55.99/hour
2 -- Weekend Service $75.99/hour
3 -- Emergency Service $99.99/hour
0 -- Exit
Select service
2

This is option 2 for $75.99 an hour.
How many hours?:
3

The cost of this service is $227.96999999999997 before tax.
Price of services provided: $227.96999999999997
Welcome to Services
*******************************************
Enter 1, 2, 3 to start or 0 to exit Services.

1 -- Regular service $55.99/hour
2 -- Weekend Service $75.99/hour
3 -- Emergency Service $99.99/hour
0 -- Exit
Select service
3

This is option 3 for $99.99 an hour.
How many hours?:
4

The cost is $399.96 before tax.
Price of services: $399.96
Welcome to Services
*******************************************
Enter 1, 2, 3 to start or 0 to exit Services.

1 -- Regular service $55.99/hour
2 -- Weekend Service $75.99/hour
3 -- Emergency Service $99.99/hour
0 -- Exit
Select service
0