I am no good at this
Hello everyone out there on the internets. I am in my third week of a Java class. I am trying to show at least a small amount of progress to my instructor, so if anyone could tell me where my stupid mistakes are in this code it would be greatly appreaciated. I am getting an error in my constructor on line 36 I will put a comment there.
Thanx
import javax.swing.JOptionPane;
import java.text.*;
publicclass lunchredo
{
// Variable Declaration
privatestaticdouble appleCost;
privatestaticdouble appleQty;
privatestaticdouble breadCost;
privatestaticdouble breadQty;
privatestaticdouble cheeseCost;
privatestaticdouble cheeseQty;
privatestaticdouble wineCost;
privatestaticdouble wineQty;
privatestaticdouble budget;
privatestaticdouble totalCost;
publicstaticvoid main(String[] args)
{
}
// right here is where the error is
// constructor setting the values
Lunch()
{
appleCost = 1.09;
appleQty = 4;
breadCost = 2.55;
breadQty = 3;
cheeseCost = 5.99;
cheeseQty = 2;
wineCost = 52.06;
wineQty = 6;
String yourbudgetString;
double budget;
yourbudgetString = JOptionPane.showInputDialog(null,"Enter Your Budget.","Budget", JOptionPane.INFORMATION_MESSAGE);
budget = Double.parseDouble(yourbudgetString);
}
publicstaticdouble setTotalCost
{
totalCost = (appleCost * appleQty) + (breadCost * breadQty) + (cheeseCost * cheeseQty) + (wineCost * wineQty);
}
publicstaticdouble displayTotal(){
DecimalFormat df =new DecimalFormat("#0.00");
System.out.println(df.format(LunchCost(0.00)));
return totalCost;
}
publicstaticdouble totalExpense(double expense){
expense = budget - totalCost;
return expense;
}
publicstaticdouble displayExpense(){
DecimalFormat df =new DecimalFormat("#0.00");
System.out.println(df.format(totalExpense(0.00)));
return expense;
}
publicstaticdouble getBudget()
{
return budget;
}
publicstaticdouble setTotalCost
{
totalCost = (appleCost * appleQty) + (breadCost * breadQty) + (cheeseCost * cheeseQty) + (wineCost * wineQty);
}
publicstaticdouble getTotalCost
{
return totalCost;
}
publicstaticdouble spendBudget(double remainder)
{
double remainder = budget - totalCost;
df.format(remainder);
JOptionPane.showMessageDialog(null,"Your budget is $" + df.format(budget) +" and the total cost of the lunch is $" + df.format(totalCost) +"." +" You have $" +
df.format(remainder) +" remaining");
//If statement that decides whether or not the budget is exceeded
if (remainder < 0)
JOptionPane.showMessageDialog(null,"You have exceeded your budget. Please go home and get more money!");
else
JOptionPane.showMessageDialog(null,"You have not exceeded your budget.");
}
//Output Section
privatestaticdouble lunchOutput()
{
System.out.println("Price of Apples per pound: $" + df.format(appleCost));
System.out.println("Price of Bread per loaf: $" + df.format(breadCost));
System.out.println("Price of Cheese per pound: $" + df.format(cheeseCost));
System.out.println("Price of Wine per bottle: $" + df.format(wineCost));
System.out.println("Total Price of all items: $" + df.format(totalCost));
System.out.println("Your Budget: $" + df.format(budget));
System.out.println("You have: $" + df.format(remainder));
}
System.exit(0);
}
}

