帮我解一道简单的C++编程题(我是初学者)

来源:百度知道 编辑:UC知道 时间:2024/07/02 05:08:40
write a program that computes the tax and tip of a restaurant bill for a patron with a cost of RM50.60.The tax should be 10% of the meal cost.The tip should be 5% of the total after adding the tax.Display the cost,tax amount,tip amount and total bill on the screen.

#include <iostream>

const double cost = 60.60
using namespace std;

int main()
{
double tax;
double tip;

tax = 0.1 * bill;
tip = 0.05 * (cost + tax);

cout << "cost: " << cost << endl;
cout << "tax: " << tax << endl;
cout << "tip: " << tip << endl;
cout << "toal bill: " << (cost + tax + tip) << endl;

return 0;

}

#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
double cost = 50.60;

double tax = 0.1 * cost;
double tip = 0.05 * (cost + tax);
double total = cost + tax + tip;

cout << setiosflags(ios::fixed) << setprecision (2);
cout << "cost: " << cost << endl;
cout << &