Slash and 2 digit number entering

Hello !

I am having a small issue with my code, mainly I'm not sure how to do this. Basically, lines 79-82, where the user enters in their birthday & birthyear, I want to make it such that the user can only enter in two digits for each number they have to enter. I also want to know how I can have a default slash in there so when they're entering, it hops over the slash so they can enter in their year.

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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;

class BirthDay
{
private:
	int Birthday; // Birthday
	int BirthYear;
	string Name; // NameofPerson
	int HowManyP;
	double presentprice; // price of present

public:

	void CardInfo(int b, int by, string n, int hmp, double cost); // Prototype

	int getBirthday()
	{
		return Birthday;
	}
	
	int getBirthYear()
	{
		return BirthYear;
	}

	string getName()
	{
		return Name;
	}

	int getHowManyP()
	{
		return HowManyP;
	}

	double getpresentprice()
	{
		return presentprice;
	}
};

// Implementation code for InventoryItem class function storeInfo
void BirthDay::CardInfo(int b, int by, string n, int hmp, double cost)
{
	Birthday = b;
	BirthYear = by;
	Name = n; 
	HowManyP = hmp;
	presentprice = cost;
}

// Function prototypes for client program
void CardInfo(BirthDay&); // Receives an object by reference
void showValues(BirthDay); // Receives an object by value


int main()
{
	BirthDay info; 

	CardInfo(info);
	showValues(info);
	system("pause");
	return 0;
}


void CardInfo(BirthDay &card)
{
	int Birthday; // Local variables to hold user input
	int BirthYear;
	string Name;
	int hmp;
	double presentprice;

	// Get the data from the user
	cout << "~~ Please enter your info for your birthday ~~ \n" << endl;
	cout << "Birthday [ex: 06 95 ]: ";
	cin >> Birthday >> BirthYear;
	cout << "Your Name: ";
	cin.get(); // Move past the '\n' left in the
	// input buffer by the last input
	getline(cin, Name);
	cout << " How many Presents do you want ? ";
	cin >> hmp;
	cout << " How much money do you have to spend on your party ? ";
	cin >> presentprice;

	// Store the data in the InventoryItem object
	card.CardInfo(Birthday, BirthYear, Name, hmp, presentprice);
}


void showValues(BirthDay card)
{
	cout << fixed << showpoint << setprecision(2) << endl;
	cout << "Birthday : " << card.getBirthday() << " / " << card.getBirthYear() << endl;
	cout << "Name : " << card.getName() << endl;
	cout << "Presents you want: " << card.getHowManyP() << endl;
	cout << "Price able to spend : $" << card.getpresentprice() << endl;
}
bumping this ! :)
If you want to automatically output a / between the fields, you're going to have to deal with the input one character at a time by calling getchar() repeatedly.
I also want to know how I can have a default slash in there so when they're entering, it hops over the slash so they can enter in their year.

You can't do this using standard C++.
Thank you both very much for your help !
Topic archived. No new replies allowed.