A company provides 4 different services whose costs are as follows:
Service 1: $100
Service 2: $200
Service 3: $300
Service 4: $400
Write a Java application that reads the service(s) provided to a particular customer then calculates and display the total charge of all services provided. You should be able to use some technique we learned in class to determine when program should stop looping and then display the final results. Perhaps end the program when “0” is entered. Note: The GUI is not required.
Here is what I have so far:
import java.util.Scanner;
public class Service2 {
public static void main(String agrs []){
Scanner input = new Scanner(System.in);
int service1 = 100;
int service2 = 200;
int service3 = 300;
int service4 = 400;
System.out.println("Enter service number, (1-4), (the program exits if the input is 0): ");
int data = input.nextInt();
// keep reading data until the input is 0
int sum = 0;
while (data != 0){
sum +=data;
System.out.println("Enter service number, (1-4), (the program exits if the input is 0): ");
data = input.nextInt();
}
System.out.println("The sum is " + sum);
} // end main
} // end