Answer:
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
double total = 0;
double fPrice, sPrice, tPrice;
int firstN = 0, secdN = 0, thirdN = 0, fTime, sTime, tTime;
int totalT = 0;
isEnd = "n";
for (;;){
if (isEnd == "y"){
break;
}
Scanner in = new Scanner(System.in);
int option = in.nextInt();
switch (option){
case 1:
fPrice = 2.50;
fTime = 5;
System.out.print("Enter number of items: ");
firstN += in.nextInt();
totalT += fTime * firstN;
total += fPrice * firstN;
break,
case 2:
sPrice = 3.75;
sTime = 7;
System.out.print("Enter number of items: ");
secdN += in.nextInt();
totalT += sTime * secdN;
total += sPrice * secdN;
break,
case 3:
tPrice = 5.99;
tTime = 12;
System.out.print("Enter number of items: ");
thirdN += in.nextInt();
totalT += tTime * thirdN ;
total += tPrice * thirdN;
break,
default:
System.out.println("Looking forward to the Weekend");
}
System.out.print("Do you want to end the order? y/n: ");
isEnd = in.nextLine();
}
System.out.println("Number of Type 1 candles bought : "+firstN);
System.out.println("Number of Type 2 candles bought : "+secdN);
System.out.println("Number of Type 3 candles bought : "+thirdN);
System.out.println("Total cost is : "+total);
System.out.println("Total burn time is : "+totalT);
double costPerBurn = (totatT * 60) / total;
System.out.println("Cost per minute : "+ costPerBurn);
}
}
Explanation:
The Java program creates a continuous for-loop statement that gets the candle type, price and amount ordered from a switch and accumulates the total cost and burn time of the candles bought and the cost per minute burn of the candles consecutively.