Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // import-list
- import java.text.DecimalFormat;
- import java.util.Scanner;
- /**
- * Emits a recipe for some food
- *
- * @author Kevin Vo
- * @version 9/5/12
- *
- * Enhancements done:
- * ---- LIST ANY ENHANCEMENTS YOU HAVE DONE HERE ----
- * Pan size computation isn't proportional to the number of serving.
- * Converts to higher units for large numbers.
- */
- public class Recipe {
- // this is the formatting object
- private static DecimalFormat df = new DecimalFormat("##.##");
- /**
- * This is the main method for this program. It prompts the user and
- * then prints the recipe.
- *
- * This starter file does not contain the completed program. In fact,
- * it does nothing but prompt the user for the 'enter' key and then
- * quits.
- *
- * @param args command-line arguments
- */
- public static void main(String[] args) {
- // ****** YOUR MODIFICATIONS SHOULD START HERE ******
- // our scanner object
- Scanner keyboard = new Scanner(System.in);
- // THE FOLLOWING IS JUST AN EXAMPLE. CS 203 students should delete
- // (or modify) the lines below.
- System.out.print("What is your name? ");
- String name = keyboard.nextLine();
- System.out.println("Your name is "+name+".");
- System.out.print("What kind of sauce do you want? ");
- String sauce = keyboard.nextLine();
- System.out.println("You want "+sauce+" sauce.");
- System.out.print("How many servings do you want? ");
- int serv = keyboard.nextInt();
- System.out.println("You want "+serv+" servings.");
- System.out.println();
- if ((serv == 0 ))
- System.out.println("Why did you run this file if you didn't want any of\n"+name+"'s Lasagna with "+sauce+" Sauce?\n\nYou must not be very hungry...");
- else
- if ((serv <0 ))
- System.out.println("I don't even think "+serv+" servings of "+name+"'s Lasagna with "+sauce+" Sauce\nis possible...");
- else{
- System.out.println(""+name+"'s Lasagna with "+sauce+" Sauce ("+serv+" servings)");
- //servings
- String servs = df.format(serv);
- String servcups = df.format(serv/8);
- String servpints = df.format(serv/16);
- String servquarts = df.format(serv/32);
- String servgals = df.format(serv/128);
- //meat = lbs
- double sausage = (serv*0.08333);
- String sausages = df.format(sausage);
- double dabeef = (serv*0.0625);
- String dabeefs = df.format(dabeef);
- //onion/tomato = oz
- double onion = (serv*0.33328);
- String onions = df.format(onion);
- String onioncups = df.format(onion/8);
- String onionpints = df.format(onion/16);
- String onionquarts = df.format(onion/32);
- String oniongals = df.format(onion/128);
- double tomato = (serv*0.21166);
- String tomatos = df.format(tomato);
- String tomatocups = df.format(tomato/8);
- String tomatopints = df.format(tomato/16);
- String tomatoquarts = df.format(tomato/32);
- String tomatogals = df.format(tomato/128);
- //sugar = oz
- double sugar = (serv*0.33332);
- String sugars = df.format(sugar);
- String sugarcups = df.format(sugar/8);
- String sugarpints = df.format(sugar/16);
- String sugarquarts = df.format(sugar/32);
- String sugargals = df.format(sugar/128);
- //cheese = oz
- double rcheese = (serv*1.333);
- String rcheeses = df.format(rcheese);
- String rcheesecups = df.format(rcheese/8);
- String rcheesepints = df.format(rcheese/16);
- String rcheesequarts = df.format(rcheese/32);
- String rcheesegals = df.format(rcheese/128);
- double mcheese = (serv*1.333);
- String mcheeses = df.format(mcheese);
- String mcheesecups = df.format(mcheese/8);
- String mcheesepints = df.format(mcheese/16);
- String mcheesequarts = df.format(mcheese/32);
- String mcheesegals = df.format(mcheese/128);
- //water = oz
- double water = (serv*0.33328);
- String waters = df.format(water);
- String watercups = df.format(water/8);
- String waterpints = df.format(water/16);
- String waterquarts = df.format(water/32);
- String watergals = df.format(water/128);
- //gal > quart > pint > cup > oz > tbsp > tsp
- System.out.println("Italian Sausage ("+sausages+" lbs)");
- System.out.println("Ground Beef ("+dabeefs+" lbs)");
- if ((onion >128 ))
- System.out.println("Onions ("+oniongals+" gals)");
- else
- if ((onion >=32) && (onion<128))
- System.out.println("Onions ("+onionquarts+" quarts)");
- else
- if ((onion >=16) && (onion<32))
- System.out.println("Onions ("+onionpints+" pints)");
- else
- if ((onion >= 8) && (onion<16))
- System.out.println("Onions ("+onioncups+" cups)");
- else
- System.out.println("Onions ("+onions+" oz)");
- if ((tomato >128 ))
- System.out.println("Tomatoes ("+tomatogals+" gals)");
- else
- if ((tomato >=32) && (tomato<128))
- System.out.println("Tomatoes ("+tomatoquarts+" quarts)");
- else
- if ((tomato >=16) && (tomato<32))
- System.out.println("Tomatoes ("+tomatopints+" pints)");
- else
- if ((tomato >= 8) && (tomato<16))
- System.out.println("Tomatoes ("+tomatocups+" cups)");
- else
- System.out.println("Tomatoes ("+tomatos+" oz)");
- if ((serv >128 ))
- System.out.println(sauce+" sauce ("+servgals+" gals)");
- else
- if ((serv >=32) && (serv<128))
- System.out.println(sauce+" sauce ("+servquarts+" quarts)");
- else
- if ((serv >=16) && (serv<32))
- System.out.println(sauce+" sauce ("+servpints+" pints)");
- else
- if ((serv >= 8) && (serv<16))
- System.out.println(sauce+" sauce ("+servcups+" cups)");
- else
- System.out.println(sauce+" sauce ("+servs+" oz)");
- if ((rcheese >128 ))
- System.out.println("Ricotta Cheese ("+rcheesegals+" gals)");
- else
- if ((rcheese >=32) && (rcheese<128))
- System.out.println("Ricotta Cheese ("+rcheesequarts+" quarts)");
- else
- if ((rcheese >=16) && (rcheese<32))
- System.out.println("Ricotta Cheese ("+rcheesepints+" pints)");
- else
- if ((rcheese >= 8) && (rcheese<16))
- System.out.println("Ricotta Cheese ("+rcheesecups+" cups)");
- else
- System.out.println("Ricotta Cheese ("+rcheeses+" oz)");
- if ((mcheese >128 ))
- System.out.println("Mozzarella Cheese ("+mcheesegals+" gals)");
- else
- if ((mcheese >=32) && (mcheese<128))
- System.out.println("Mozzarella Cheese ("+mcheesequarts+" quarts)");
- else
- if ((mcheese >=16) && (mcheese<32))
- System.out.println("Mozzarella Cheese ("+mcheesepints+" pints)");
- else
- if ((mcheese >= 8) && (mcheese<16))
- System.out.println("Mozzarella Cheese ("+mcheesecups+" cups)");
- else
- System.out.println("Mozzarella Cheese ("+mcheeses+" oz)");
- if ((sugar >128 ))
- System.out.println("Sugar ("+sugargals+" gals)");
- else
- if ((sugar >=32) && (sugar<128))
- System.out.println("Sugar ("+sugarquarts+" quarts)");
- else
- if ((sugar >=16) && (sugar<32))
- System.out.println("Sugar ("+sugarpints+" pints)");
- else
- if ((sugar >= 8) && (sugar<16))
- System.out.println("Sugar ("+sugarcups+" cups)");
- else
- System.out.println("Sugar ("+sugars+" oz)");
- if ((water >128 ))
- System.out.println("Water ("+watergals+" gals)");
- else
- if ((water >=32) && (water<128))
- System.out.println("Water ("+waterquarts+" quarts)");
- else
- if ((water >=16) && (water<32))
- System.out.println("Water ("+waterpints+" pints)");
- else
- if ((water >= 8) && (water<16))
- System.out.println("Water ("+watercups+" cups)");
- else
- System.out.println("Water ("+waters+" oz)");
- System.out.println("Lasagna Noodles ("+servs+")");
- int containerl = 9^(serv^1/2);
- int containerw = 4^(serv^1/2);
- System.out.println();
- System.out.println("Cook the sausage, ground beef and onions over medium heat until well cooked.\nStir for 5 minutes, adding in some water and tomatoes. Add a thin layer of\nthe mixture to the bottom of a "+containerl+" by "+containerw+" inch pan. On top of this, add\nlasanga noodles and a small layer of cheese on top of the meat. Repeat\nthis until the pan is full.");
- }
- // ****** YOUR MODIFICATIONS SHOULD END HERE ******
- }
- /**
- * This method produces a string with a specified number of blanks.
- * CS 203 students should not need to modify anything below
- *
- * @param count the number of the blanks in the string
- * @return a string consisting of the specified number of blanks
- */
- private static String repeatBlanks(int count) {
- if (count <= 0) return ""; // if no blanks required, return empty string
- else return " "+repeatBlanks(count-1); // otherwise produce string
- }
- }
Add Comment
Please, Sign In to add comment