package compassignment;
import java.util.Scanner;
public class Main {
{
//IF I MAKE THESE ARRAYS STATIC, EVERYTHING IN THE ARRAYS BECOMES AN ERROR
double[] MET = new double[30]; //Creating array for MET values
MET[0] = 6.83; MET[1] = 8.00; MET[2] = 8.00;
MET[3] = 4.50; MET[4] = 1.50; MET[5] = 1.80;
MET[6] = 4.50; MET[7] = 8.00; MET[8] = 2.10;
MET[9] = 6.00; MET[10] = 2.18; MET[11] = 3.01;
MET[12] = 2.07; MET[13] = 3.66; MET[14] = 10.00;
MET[15] = 1.58; MET[16] = 1.64; MET[17] = 2.72;
MET[18] = 10.00; MET[19] = 18.00; MET[20] = 0.92;
MET[21] = 7.00; MET[22] = 9.50; MET[23] = 1.82;
MET[24] = 2.93; MET[25] = 2.05; MET[26] = 3.80;
MET[27] = 5.22; MET[28] = 6.00; MET[29] = 3.00;
int[] Food = new int[35]; //Creating array for Food values
Food[0] = 301; Food[1] = 725; Food[2] = 438;
Food[3] = 1179; Food[4] = 580; Food[5] = 288;
Food[6] = 691; Food[7] = 334; Food[8] = 476;
Food[9] = 399; Food[10] = 808; Food[11] = 1110;
Food[12] = 423; Food[13] = 605; Food[14] = 516;
Food[15] = 606; Food[16] = 22; Food[17] = 1980;
Food[18] = 622; Food[19] = 33; Food[20] = 362;
Food[21] = 694; Food[22] = 232; Food[23] = 1869;
Food[24] = 501; Food[25] = 684; Food[26] = 1045;
Food[27] = 1012; Food[28] = 627; Food[29] = 207;
Food[30] = 148; Food[31] = 232; Food[32] = 327;
Food[33] = 583; Food[34] = 60;
}
public static void main(String[] args)
{
choice();
}
private static void choice() //Code for choosing either Food or Activity
{
System.out.println("Welcome to the Energy Balancer. (QUIT to exit)");
System.out.println("==============================================");
System.out.print("Are you balancing food or activity?"
+ " (Help/FOOD/ACTIVITY)");
Scanner scan = new Scanner(System.in);
String input = scan.next();
if (input.equalsIgnoreCase("food"))
foodchoice();
else if (input.equalsIgnoreCase("activity"))
activitychoice();
else die();
}
private static void foodchoice()
{
System.out.print("Please enter the user's weight in kg: ");
Scanner scan = new Scanner (System.in);
int weight = scan.nextInt();
System.out.println("Indicate the type of food and number of serves "
+ "from the list below:");
System.out.println("0. Apples\n1. Baked Beans\n2. Banana"
+ "\n3. Beef Steak\n4. Beer\n5. Beetroot\n6. Bread - Pita"
+ "\n7. Bread - White\n8. Cheese - Cheddar\n9. Chick Peas"
+ "\n10. Chicken Breast\n11. Chocolate\n12. Corn Flakes"
+ "\n13. French Fries\n14. Fruit Juice\n15. Ice Cream - Vanilla"
+ "\n16. Lettuce\n17. Meat Pie\n18. Milk - Regular"
+ "\n19. Mushrooms - Raw\n20. Oranges\n21. Peanuts"
+ "\n22. Peas\n23. Pork Steak\n24. Porridge - Instant"
+ "\n25. Potato\n26. Potato Crisps\n27. Rice - White"
+ "\n28. Soft Drink\n29. Strawberries\n30. Tofu"
+ "\n31. Tomato\n32. Tuna\n33. Yoghurt - Plain\n34. Zucchini");
int type = scan.nextInt();
int serves = scan.nextInt();
if (type > 34)
die();
else if (type < 0) //making sure only positive numbers are entered,
die(); //as well as type being less than 35.
if (serves < 0)
die();
int kcal = MET[type];
//^HERE IS WHERE IM HAVING TROUBLE^ The "MET" has an error, saying "variable MET not found"
}
}