JAVA
java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import java.util.*;
public class Program
{
public static void main(String[] args) {
// List of menu
Dictionary<String, Integer> menu = new Hashtable<>();
menu.put("Nachos", 6);
menu.put("Pizza", 6);
menu.put("Cheeseburger", 10);
menu.put("Water", 4);
menu.put("Coke", 5);
// For input, and split with space (" ")
Scanner input = new Scanner(System.in);
String[] pick = input.nextLine().split(" ");
double total = 0;
// for calculation menu
for (String a : pick){
try{
total += menu.get(a);
}catch(Exception e){
total += menu.get("Coke");
}
}
// we get total of menu, now the tax
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run