I am new to Java and have a class assignment that I need help with..
The assignment is to write a program that computes the tax and tip for a restaurant bill. User is to enter the total amount of the bill. Tax is 6.75% of the bill. The tip is 15% of the meal after tax has been added. The meal charge, tax, tip, and total should be printed on the screen..
* To change this template, choose Tools | Templates
* and open the template in the editor.
This program demonstrates using dialogs with
public class Restaurant
public static void main(String args)
inputString; //For reader's input
int total; // The user's total bill.
int taxAmount; //6.75 of the user's total bill
int totalMeal; //Bill after tax has been added
int tip; // 15 percent of the totalMeal
int overall; // The total including tax and tip
// Get the user's total bill.
JOptionPane.showInputDialog("What is " +
"the total bill? ");
//Convert the input to an int.
total = Integer.parseInt(inputString);
// Calculate the tax amount.
taxAmount = 6.75/100 * total;
// Calculate the total meal after tax has been added.
totalMeal = taxAmount + total
//Calculate the tip
tip = 15/100 * totalMeal
// Calculate the entire bill.
overall = totalMeal + tip;
System.out.println("The taxed amount is" + taxAmount);
System.out.println("The tip amount is" + tipAmount);
System.out.println("The total bill is" + overall)
You have a few easy errors, like forgetting semicolons at the end of lines, and you forgot to put the word "String" before the first instance of variable "inputString", and you use a variable name in one of the last lines that you never defined. There are some precision-loss problems too... the compiler tells you the errors you have.