Skip to main content

===Please Help!!=== I'm getting too many errors!

1 reply [Last post]
weston1373
Offline
Joined: 2011-06-16
Points: 0

Okay well I'm realllllyyy new to java, my final project is due tomorrow and it needs to have the following within it: accessor methods, modifier methods, return statement, parameters, arguments, for loop, if statements, random number, 2 constructors and 2 string methods. I have this lame project typed up and I would really appreciate any help you can offer me (:

p.s. sorry for the messy code and errors, I'm REALLY new to this :/

import java.util.*;

import java.lang.String;

public class FinalProject {

public static void waffleRecipe() {

double flour, bakingSoda, bakingPowder, sugar, salt, eggs, vegetableOil;

int amount;

System.out.println("How many waffles are you gon' eat?");

amount = input.nextInt();

flour = amount * 0.25; //measured in cups

bakingSoda = amount * 0.125; // measured in teaspoons

sugar = amount * 0.25; //measured in teaspoons

salt = amount * 0.125; //measured in teaspoons

eggs = amount * 0.375;

vegetableOil = amount * 0.75; //measured in teaspoons

System.out.println("You need a waffle iron,");

System.out.println("You need " + flour + " cups of flour,");

System.out.println("You need " + bakingSoda + " teaspoons of baking soda and baking powder,");

System.out.println("You need " + sugar + " teaspoons of sugar,");

System.out.println("You need " + salt + " teaspoons of salt,");

System.out.println("You need " + eggs + " eggs.");

System.out.println("You need " + vegetableOil + " teaspoons of vegetable oil.");

}

public static void pancakeRecipe() {

double flour, bakingSoda, bakingPowder, sugar, salt, eggs, vegetableOil, milk;

int amount;

System.out.println("How many pancakes can yo stomach handle?");

amount = input.nextInt();

flour = amount * 0.33; //measured in cups

bakingSoda = amount * 0.125; // measured in teaspoons

bakingPowder = amount * 0.25; //measured in teaspoons

sugar = amount * 1; //measured in teaspoons

salt = amount * 0.125; //measured in teaspoons

eggs = amount * 0.375;

vegetableOil = amount * 2; //measured in teaspoons

milk = amount * 0.33; //measured in cups

System.out.println("You need " + flour + " cups of flour,");

System.out.println("You need " + bakingSoda + " teaspoons of baking soda,");

System.out.println("You need " + bakingPowder + " teaspoons of baking powder,");

System.out.println("You need " + sugar + " teaspoons of sugar,");

System.out.println("You need " + salt + " teaspoons of salt,");

System.out.println("You need " + eggs + " eggs.");

System.out.println("You need " + milk + " cups of milk,");

System.out.println("You need " + vegetableOil + " teaspoons of vegetable oil.");

}

public static void crepeRecipe() {

double flour, salt, eggs, water, milk, butter;

int amount;

System.out.println("How many crepes will be gettin' in your belly?");

amount = input.nextInt();

flour = amount * 0.25; //measured in cups

salt = amount * 0.125; //measured in teaspoons

eggs = amount * 0.5;

water = amount * 2; //measured in teaspoons

milk = amount * 2; //measured in tablespoons

butter = amount * 1.25; //measured in teaspoons

System.out.println("You need " + flour + " cups of flour,");

System.out.println("You need " + water + " tablepoons of water,");

System.out.println("You need " + milk + " tablepoons of milk,");

System.out.println("You need " + salt + " teaspoons of salt,");

System.out.println("You need " + eggs + " eggs.");

System.out.println("You need " + butter + " teaspoons of melted butter.");

}

public static void frenchToastRecipe() {

double sugar, eggs, vegetableOil, milk, vanilla, bread;

int amount;

System.out.println("How many pieces of French Toast shall you devour?");

amount = input.nextInt();

vanilla = amount * 0.125; //measured in teaspoons

bread = amount;

sugar = amount * 0.0625; //measured in teaspoons

eggs = amount * 0.375;

vegetableOil = amount * 1; //measured in teaspoons

milk = amount * 0.125; //measured in cups

butter = amount * 1; //measured in tablespoons

System.out.println("You need " + bread + " slices of bread,");

System.out.println("You need " + butter + " tablepoons of butter,");

System.out.println("You need " + sugar + " teaspoons of sugar,");

System.out.println("You need " + salt + " teaspoons of salt,");

System.out.println("You need " + eggs + " eggs.");

System.out.println("You need " + milk + " cups of milk and one teaspoon as well,");

System.out.println("You need " + vegetableOil + " teaspoons of vegetable oil.");

System.out.println("You need " + vanilla + " teaspoons of vanilla extract,");

}

public static void main(String[] args) {

String start, yn;

int num, yn;

Random rand1 = new Random();

Scanner input = new Scanner(System.in);

System.out.println("Does your tummy have the rumblies?");

yn = input.nextLine();

//do {

System.out.println("Type in the breakfast food you want the recipe for (type elephant for random recipe): ");

start = input.nextLine();

start = start.toLowerCase();

if (start .equals ("waffle")) {

waffleRecipe();

}

else if (start .equals ("pancake")) {

pancakeRecipe();

}

else if (start .equals ("crepe")) {

crepeRecipe();

}

else if (start .equals ("french toast")) {

frenchToastRecipe();

}

else if (start .equals ("elephant")) {

num = rand1.nextInt(4) + 1;

if (num == 1) {

pancakeRecipe();

}

else if (num == 2) {

crepeRecipe();

}

else if (num == 3) {

frenchToastRecipe();

}

else if (num == 4) {

waffleRecipe();

}

}

else {

System.out.println("You messed something up man, try again.");

//} while (yn .equals ("yes"));

//}

}

}

}

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
bwillcott
Offline
Joined: 2007-06-01
Points: 0

Ok I am looking at your code. Firstly, I would suggest you use an IDE, like Netbeans: http://netbeans.org/

Now the code. Can I assume that "input" is a console input stream? You don't have it defined.
Also, "yn" is defined twice in "main()", and "butter" and "salt" are not defined in "frenchToastRecipe()".

Do you still want help with this?

Brad.