In: Computer Science
//that as output. After all items have been entered, display the total price for the order.
Explanation:I have written the code as mentioned and have also shown the output by using the main method, please find the image attached with the answer.Please upvote if you liked my answer and comment if you need any modification or explanation.
//code
import java.util.Scanner;
public class JumpinJiveCoffeeShop {
public static void main(String[] args) {
Scanner input = new
Scanner(System.in);
float[] addinsPrice = {0.89f,
0.25f, 0.59f, 1.50f, 1.75f};
int choice = 0;
float totalPrice = 2;
while (true) {
System.out.print("Welcome to Jumpin'Jive coffee shop:\n"
+ "1)whipper cream \n" +
"2)cinnamon\n"
+ "3)chocolate sauce\n" +
"4)amaretto\n"
+ "5)irish whiskey\n" +
"-1)Exit\n"
+ "please select a
choice:");
choice =
input.nextInt();
if (choice ==
-1)
break;
switch (choice)
{
case 1 :
System.out.println("whisper
cream "
+ addinsPrice[choice - 1] + " added");
totalPrice +=
addinsPrice[choice - 1];
break;
case 2 :
System.out.println(
"cinnamom " + addinsPrice[choice - 1] + "
added");
totalPrice +=
addinsPrice[choice - 1];
break;
case 3 :
System.out.println("chocolate
sauce "
+ addinsPrice[choice - 1] + " added");
totalPrice +=
addinsPrice[choice - 1];
break;
case 4 :
System.out.println("Sorr, we
do not carry amaretto.");
break;
case 5 :
System.out.println("irish
whiskey "
+ addinsPrice[choice - 1] + " added");
totalPrice +=
addinsPrice[choice - 1];
break;
case 6 :
break;
}
}
System.out.println("The total
price for the order is "
+ Math.round(totalPrice * 100.0) / 100.0);
input.close();
}
}
Output: