In: Computer Science
Write a program that will calculate a 15% tip and a 13% tax on a meal price. The user will enter the meal price and the program will calculate tip, tax, and the total. The total is the meal price plus the tip plus the tax. Your program will then display the values of tip, tax, and total. Please format the output, also the round up to 2 decimal places.
HERE IS THE PYTHON CODE FOR THE QUESTION:
price = float(input("Enter the meal price: "))
tip = (15/100.0) *price
tax = (13/100.0) * price
print("Total bill value:")
print("Meal price: %.2f" %price)
print("Tip : %.2f" %tip)
print("Tax : %.2f" %tax)
print("Total: %0.2f" %(price+tip+tax))
________________________________________________________________________________________________
HERE is the c++ code:
#include<iostream>
using namespace std;
int main()
{
double price,tax,tip;
cout<<"Enter the price of the meal: ";
cin>>price;
tax = price * (13/100.0);
tip = price * (15/100.0);
cout<<"Total bill value: \n";
printf("Meal price %.2f \n", price);
printf("Tax %.2f \n", tax);
printf("Tip %.2f \n", tip);
printf("Total price: %.2f \n", price+tax+tip);
return 0;
}