Java Task 3 Restaurant Bill Write a program that computes t

Java

Task #3 – Restaurant Bill

Write a program that computes the tax and tip on a restaurant bill.

For your input, the program should ask the user to enter the charge for the meal and how much of a tip (as a percentage of the bill). The tax should be 6.0% of the meal charge. The tip should be user value entered of the total before adding the tax. For your output, the program should display the meal charge, tax amount, tip amount, and total bill.

I expect you to provide me with the source code for this task.

Solution

RestarentBillDemo.java


import java.util.Scanner;//package for keyboard inputting


public class RestarentBillDemo {//main class
  
public static void main(String args[])
{//main method
  
    float mealcharge;//variable declaration
    float tip_percentage,tax,tip,totalbill;
    System.out.print(\"Enter the charge for the meal :\");
    Scanner sc=new Scanner(System.in);
    try{
    mealcharge=sc.nextFloat();//key board inputting of meal charge
    System.out.print(\"Enter the tip as per percentage of the bill :\");
    tip_percentage=sc.nextFloat();//key board inputting of tip percentage
    tax=(mealcharge*6)/100;// 6percent tax
    tip=(mealcharge*tip_percentage)/100;//calculating tip amt
    System.out.println(\"Meal charge   :\"+mealcharge);
    totalbill=mealcharge+tip+tax;//total bill calculation
    System.out.println(\"Tip   amount :\"+tip);
    System.out.println(\"Tax amount    :\"+tax);
    System.out.println(\"Total bill \"+totalbill);
    }
    catch(Exception e)
    {
        System.out.println(\"Please enter nummerical only only\");
    }
}
}


output

Enter the charge for the meal :1000
Enter the tip as per percentage of the bill :5
Meal charge   :1000.0
Tip   amount :50.0
Tax amount    :60.0
Total bill 1110.0

Java Task #3 – Restaurant Bill Write a program that computes the tax and tip on a restaurant bill. For your input, the program should ask the user to enter the

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site