The program just let's out all my cout commands

how do i fix this?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <iostream>
#include <string>
using namespace std;
int main()
{
	double restaurant, date, bill, tax_rate, tip, num_ppl, total_forppl, amount, total_tax, total_tip, total;
	cout << "Please enter the restaurants name: ";
	cin >> restaurant;
	cout << "\nPlease enter the date in the format of mm/dd/yyyy: ";
	cin >> date;
	cout << "\nEnter bill amount: ";
	cin >> bill;
	cout << "\nEnter tax rate: ";
	cin >> tax_rate;
	cout << "\nEnter tip in %: ";
	cin >> tip;
	total_tax = bill * tax_rate;
	total_tip = bill * tip;
	total = total_tax + total_tip + bill;
	cout << "\nTotal including tax of" << tax_rate << "and tip of" << tip << "is " << total;
	cout << "\nEnter number of people to dive by: ";
	cin >> num_ppl;
	total_forppl = total / num_ppl;
	cout << "\nAmount for each of" << num_ppl << "person(s): " << total_forppl;


	system("pause");
	return 0;
}
Last edited on
You have declared all variables as doubles. Your program works fine as long as you input a number for the name, date, etc.
closed account (48T7M4Gy)
A couple of ways, and one would be to tell us where you want help/what has to be fixed? Normally this is tasked by our mind-reading team but they are away at the moment.
once i start the program and type in the restaurant name, it just displays everything in quotation marks the it says "press any key to continue" and closes the program when i type a key
what do you mean by that peter? sorry i'm kinda new to this.
On line 6 of your program you have declared all variables to have type double. This means they are all numbers. restaurant, date, and the rest of the variables are numbers, so when you use cin to read a value to these variables it expects the user to enter a number. If the user don't enters a number it fails.

I guess you want restaurant to be of type std::string. That will allow you to enter the restaurant name as text.
Last edited on
ah i see.
Fixed it! thanks so much for that. i was going crazy trying to fix it!
Topic archived. No new replies allowed.