How do i use forward slash for the input?

I'm trying to make a basic code but i can't use "/" for an input.
everything is good but when it goes to the part to enter the date and i put a forward slash, then the program skips everything. it only works if i don't use the forward slash.

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
30
31
32
33
34
35
36
37
38
39
#include <iostream>
#include <string>
using namespace std;
int main()
{
	string restaurant, rname;
	double date;
	double bill;
	double tax_rate;
	double tip;
	double num_ppl;
	double total_forppl;
	double amount;
	double total_tax;
	double total_tip;
	double total;
	cout << "Please enter the restaurants name: ";
	cin >> restaurant >> rname;
	cout << "\nPlease enter the date in the format of mm/dd/yyyy: ";
	cin >> date;
	cout << "\nEnter bill amount: ";
	cin >> bill;
	cout << "\nEnter tax rate in %: ";
	cin >> tax_rate;
	cout << "\nEnter tip in %: ";
	cin >> tip;
	total_tax = .01 * tax_rate * bill;
	total_tip = .01 * tip * bill;
	total = total_tax + total_tip + bill;
	cout << "\nTotal including tax of " << tax_rate << "% and tip of " << tip << "% is $" << total << endl;
	cout << "\nEnter number of people to divide by: ";
	cin >> num_ppl;
	total_forppl = total / num_ppl;
	cout << "\nAmount for each of " << num_ppl << " person(s): $" << total_forppl << endl;


	system("pause");
	return 0;
}
You have date as type double. 09/21/2015, for example, is not a double, float, or integer.
which one do i put for the date
admkrk mean change data type of date into a data type that able to store some / and numbers
I suggest string for date
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>

int main()
{
    std::cout << "\nPlease enter the date in the format of mm/dd/yyyy: " ;

    int month ;
    int day ;
    int year ;

    char separator ;
    if( std::cin >> month >> separator && separator == '/' &&
        std::cin >> day >> separator && separator == '/' && std::cin >> year )
    {
       std::cout << "you entered " << month << '/' << day << '/' << year << '\n' ;
    }
    else std::cerr << "badly formed input\n" ;

    // TODO: validate date
}
Thanks, LendraDwi! it works perfectly now.
Thanks for the information.
Topic archived. No new replies allowed.