Piggy bank program

How do i go about getting a name from a user and using it throughout the entire program im coding. itll be used quite frequently. its a piggy bank program.so far thats what i have. any tips?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <string>
#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
	// DECLARING THE VARIABLES
	int name, saved, total, quarters, dimes, nickles, pennies, weeks;
	std::cout.precision(6);
	
	// Title Screen
	cout << "Welcome to the Piggy Bank Program!" << endl;
	cout << "Press Enter to Continue";
	cin.ignore();
	cout << "Hi, can I please have your name so I can address you properly?";
	cin >> name;
	cout << "Wow!" <<name;
	cout << "I like that name!";
	system("pause");
	return 0;
}
line 17: You've declared name to be an int. Does everyone you know go by a number instead of a name?

line 1: You've included the <string> header, but don't have any string variables. You might want to consider making name a string.



Topic archived. No new replies allowed.