1. Write a program that computes the tax and tip on a restaurant bill that has a
ID: 3628899 • Letter: 1
Question
1. Write a program that computes the tax and tip on a restaurant bill that has a $55.03 meal cost. The tax is 9.25% of the meal cost. Tip is 10% of the total after adding the tax. Write the program so that the output shows that the dollar ($) and the decimal points are aligned and that all numbers show two decimal places.2. Assume that the variable a= 1, b= 6, c= 5, d= 9 state whether each of the following Boolean expressions are true or false:
A) a==6
B) 8<=(a+b)
C) c!=5
D) (a+4)>5
E) d/2<4
3. Write a program that asks for the number of calories and protein grams in a food. The program should display the percentage of calories that come from protein. If the calories from protein are greater than 40% of the total colories of the food. It should display a message indicating that the food is high in protein, otherwise don't display anything. One gram of protein has four calories. Make sure that the number of calories and proteins grams are not less than 0. Also check that the numbers of calories from proteins are not greater than the total number of calories. If any of these errors occur than display an appropriate error message.
Explanation / Answer
// 1) only one question per post dude !!
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
double bill,tax,tip;
cout << "enter bill amount ";
cin >> bill;
cout << fixed;
tax = 0.925*bill;
tip = (bill+tax)*0.01;
cout << "Bill is $" << setprecision(2) << bill << endl;
cout << "Tax is $" << setprecision(2) << tax << endl;
cout << "Tip is $" << setprecision(2) << tip << endl;
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.