Вы находитесь на странице: 1из 3

// Dylan Clark, 6/4/15, final

import TerminalIO.KeyboardReader;
import java.text.DecimalFormat;
class clarkFinalExam { // this is the name of the program
public static void main(String args[]){ // this line wiill be in every main program
KeyboardReader reader = new KeyboardReader(); // making a copy of the code
KeyboardReader(someone elses code), in your program called reader
DecimalFormat twoDecimal = new DecimalFormat("0.00");
String food1, food2; //String to identify words or sentences
double cal=0, carb=0, pro=0, fat=0, cal2=0, carb2=0, pro2=0, fat2=0, finalcal=0, finalfat=0,
finalcarb=0, finalpro=0; //calories, protein, carbs, and fat
System.out.println ("Good evening!");
System.out.println ("These are the items you're able to order- Quarter Pound + Cheese,
Fish Burger, Bacon Double + Cheese, Big Breakfast, Large Fries, Hash Brown (1), and
Milkshake.");
System.out.println ("Enter your first item as spelled above"); //for the string to detect the
correct term, it has to be spelled as above
food1 = reader.readLine(); //reader.readLine so the reader can input something with the
keyboard
System.out.println ("Enter your second item");
food2 = reader.readLine();
if(food1.equals("Quarter Pound + Cheese")) cal=500;

fat=26; carb=38;

if(food1.equals("Fish Burger")) cal=370; fat=17; carb=41;

pro=17;

if(food1.equals("Bacon Double + Cheese")) cal=475;

fat=24; carb=34;

if(food1.equals("Big Breakfast")) cal=578;

fat=36; carb=40;

pro=30;

pro=28;

pro=26;

if(food1.equals("Large Fries")) cal=400; fat=17.5; carb=57; pro=6;


a certain item is chosen, then it will have a certain amount of (ex.)carbs

//if then statements...if

if(food1.equals("Hash Brown")) cal=134; fat=75;

carb=16; pro=1.5;

if(food1.equals("Milkshake")) cal=380; fat=9; carb=68; pro=11;


if(food2.equals("Quarter Pound + Cheese")) cal2=500; fat2=26; carb2=38; pro2=30;
if(food2.equals("Fish Burger")) cal2=370; fat2=17; carb2=41; pro2=17;
if(food2.equals("Bacon Double + Cheese")) cal2=475; fat2=24; carb2=34; pro2=28;
if(food2.equals("Big Breakfast")) cal2=578; fat2=36; carb2=40; pro2=26;
if(food2.equals("Large Fries")) cal2=400; fat2=17.5; carb2=57; pro2=6;
if(food2.equals("Hash Brown")) cal2=134; fat2=75; carb2=16; pro2=1.5;
if(food2.equals("Milkshake")) cal2=380;

fat2=9; carb2=68; pro2=11;

finalcal=cal+cal2; //two items chosen and the individual contents added


finalfat=fat+fat2;
finalcarb=carb+carb2;
finalpro=pro+pro2;
System.out.println ("Your total amounts are; "+finalcal+" calories, "+finalfat+" fat, "+finalcarb+"
carbohydrates, and "+finalpro+" protein.");
if(finalcal>900) System.out.println ("That's too much on the extras!!!...");
if(finalcal<=900) System.out.println ("You are fine with the calories.");
(finalcarb>85) System.out.println ("Your carbohydrates are a bit on the heavy side"); // <,>,= to
identify the (ex.) carb intake and whether or not it is too high, low, or just right
if(finalcarb<=85 && finalcarb>=20) System.out.println ("Your carbohydrate intake is just fine");
if(finalcarb<20) System.out.println ("Too little carbohydrates");
System.out.println ("Thank you :)");
// this program gives the reader a list of items to choose from. two are chosen and the
calories, protein, carbs and fat for each are identified and added individually
}}

Вам также может понравиться