My code is not applying my input and I can't figure out why. Any help is appreciated.
import java.util.Scanner; public class CoffeeCup_Driver { public static void main (String[] args) { String typeofCoffee; double height, radius, addCoffee, amount; int input; Scanner scan = new Scanner(System.in); // prompt user for the name of coffee and the height/radius of the cup System.out.print("Enter the type of Coffee: "); typeofCoffee = scan.nextLine(); System.out.print("Enter the height of coffee cup: "); height = scan.nextDouble(); System.out.print("Enter the radius of coffee cup: "); radius = scan.nextDouble(); //create a new coffee cup with the parameters entered CoffeeCup cup = new CoffeeCup (typeofCoffee, radius, height); //prints the cup object System.out.println(cup); //allow the user to enter the amount they want to pour into the cup System.out.print("Enter the amount of coffee to pour: "); amount = scan.nextDouble(); cup.addCoffee(amount); System.out.println(cup); //allow the user to enter the width of a sugar cube to add System.out.print("Enter the width of a sugar cube:"); input = scan.nextInt(); System.out.println(cup); //allow the user to enter the amount of coffee they want to drink System.out.print("Enter the amount of coffee to drink:"); amount = scan.nextDouble(); cup.drinkCoffee(amount); System.out.println(cup); //empty the coffee cup cup.emptyCup(); System.out.println("Emptying Cup..."); //print the cup object System.out.println(cup); } }
public class CoffeeCup { private double volofCup,amtofCoffee; private String typeofCoffee; private String overflow; private int emptyCup; private double volofCube; public CoffeeCup(String type, double radius, double height) { type = typeofCoffee; volofCup =Math.PI * Math.pow(radius, 2) * height; } public void emptyCup() { emptyCup = 0; } public boolean addCoffee(double amtofCoffee) { amtofCoffee += emptyCup; if(amtofCoffee >= volofCup) { amtofCoffee = volofCup; return true; } else amtofCoffee = amtofCoffee; return false; } public boolean addSugarCube(double width) { volofCube = Math.pow(width, 2); volofCube += amtofCoffee; if(amtofCoffee > volofCup) { amtofCoffee = volofCup; return true; } else{ return false; } } public void drinkCoffee(double drinkCoffee) { amtofCoffee -= drinkCoffee; if(drinkCoffee > amtofCoffee) amtofCoffee = 0; else{ this.amtofCoffee -= drinkCoffee; } } public String toString(){ String output = "Cup of Decaf Coffee " + "\n" + "Vol. of the Cup is: " + volofCup +" Cubic Centimeters\n" + "Cup is: " + amtofCoffee + "% full"; return output; } }
Those are my two programs but It seems like my main is not calling the driver when i try to enter any input. Any help is appreciated.