We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
I decided to delete the methods & start the mathematical operations directly;
here is my code and it works fine!
public class Arithmetic {
double mealCost;
int tipPercent;
int taxPercent;
double tip;
double tax;
double totalCost;
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
double mealCost = scan.nextDouble(); // original meal price
int tipPercent = scan.nextInt(); // tip percentage
int taxPercent = scan.nextInt(); // tax percentage
scan.close();
double tip= (mealCost*(tipPercent))/100.0;
double tax=(mealCost*(taxPercent/100.0));
double totalCost=(mealCost+tip+tax);
int totalRoundedCost = (int) Math.round(totalCost);
System.out.println("The total meal cost is " + totalRoundedCost+" dollars.");
Day 2: Operators
You are viewing a single comment's thread. Return to all comments →
I decided to delete the methods & start the mathematical operations directly; here is my code and it works fine! public class Arithmetic { double mealCost; int tipPercent; int taxPercent; double tip; double tax; double totalCost; public static void main(String[] args) {