어떤 가게에는 아주 간단한 메뉴만 있다. 각 음식의 항목은 숫자로 선택한다.
3 가지의 버거
1 . Cheeseburger (461 Calories)
2 . Fish Burger (431 Calories)
3 . Veggie Burger (420 Calories)
4 . no burger
3 가지 음료
1 . Soft Drink ( 130 Calories)
2 . Orange Juice (160 Calories)
3 . Milk (118 Calories)
4 . no drink
3 가지 side order(추가 주문)
1 . Fries (100 Calories)
2 . Baked Potato (57 Calories)
3 . Chef Salad (70 Calories)
4 . no side order
3 가지 디저트
1 . Apple Pie (167 Calories)
2 . Sundae (266 Calories)
3 . Fruit Cup (75 Calories)
4 . no dessert
선택한 음식의 총 칼로리를 계산 하시오.
답
package main;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int[][] arr = new int[][] {{461,431,420,0}, {130,160,118,0}, {100,57,70,0},{167,266,75,0}};
int sum = arr[0][scanner.nextInt()-1] + arr[1][scanner.nextInt()-1] + arr[2][scanner.nextInt()-1] +
arr[3][scanner.nextInt()-1];
System.out.println("Your total Calorie count is " +sum+".");
}
문제 http://59.23.150.58/30stair/calorie/calorie.php?pname=calorie
답
import java.util.Scanner;
public class Main {
}