-
-
Save fayimora/7707519 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javax.swing.*; | |
class ExamProg | |
{ | |
public static void main (String[] param) | |
{ | |
askfood(); | |
System.exit(0); | |
} | |
public static void askfood() | |
{ | |
String[] food = {"Crisps","Yoghurt","Soup","Baked Beans"}; | |
String stop = "END"; | |
String input = JOptionPane.showInputDialog("I can tell you about the salt content of the following food: \nCrisps, Yoghurt, Soup, Baked Beans \nPlease type one of the above foods or END to exit"); | |
while (input!="END") | |
{ | |
input = JOptionPane.showInputDialog("I can tell you about the salt content of the following food: \nCrisps, Yoghurt, Soup, Baked Beans \nPlease type one of the above foods or END to exit"); | |
String message = ""; | |
if (input.equalsIgnoreCase("Crisps")) | |
{ | |
message = "Crisps: That is 0.9g of sodium per 100g. The salt content is very high"; | |
} | |
else if (input.equalsIgnoreCase("Yoghurt")) | |
{ | |
message = "Yoghurt: That is 0.06g of sodium per 100g. THe salt content is low"; | |
} | |
else if (input.equalsIgnoreCase("Soup")) | |
{ | |
message = "Soup: That is 0.22 of sodium per 100g. The salt content in medium"; | |
} | |
else if (input.equalsIgnoreCase("Baked Beans")) | |
{ | |
message = "Baked Beans: That is 0.4g of sodium per 100g. The salt content is high"; | |
} | |
else if (input.equalsIgnoreCase("END")) | |
{ | |
message = "Eat healthily, goodbye"; | |
System.exit(0); | |
} | |
else | |
{ | |
message = "Sorry I don't know that one"; | |
} | |
JOptionPane.showMessageDialog(null, message); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment