-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpig_lab.cpp
More file actions
88 lines (54 loc) · 1.4 KB
/
pig_lab.cpp
File metadata and controls
88 lines (54 loc) · 1.4 KB
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
// pig_lab.cpp : not a complete program
//
#include "stdafx.h"
#include <iostream>
#include <string>
#include <iomanip>
#include "screen.h"
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
string name;
float numQuarters;
float valueQ = .25;
float numDimes;
float valueD = .10;
float numNickels;
float valueN = .05;
float numPennies;
float valueP = .01;
float total;
int wSaving;
//title screen
gotoxy(30, 10);
cout << "Piggy Bank Program!" << endl;
gotoxy(1, 23);
delay(1000);
system("cls");
//User welcome
cout << "What is your first name?" << endl;
cin >> name;
cout << "Hello! " << name << endl;
//number of coins
cout << "How many quarters do you have in the piggy bank?" << endl;
cin >> numQuarters;
cout << "How many dimes do you have in the piggy bank?" << endl;
cin >> numDimes;
cout << "How many nickles do you have in the piggy bank?" << endl;
cin >> numNickels;
cout << "How many pennies do you have?" << endl;
cin >> numPennies;
cout << "How many weeks have you been saving?" << endl;
cin >> wSaving;
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout << setprecision(2);
numQuarters = numQuarters * valueQ;
numDimes = numDimes * valueD;
numNickels = numNickels * valueN;
numPennies = numPennies * valueP;
total = numQuarters + numDimes + numNickels + numPennies;
cout << "$" << total << endl;
system("pause");
return 0;
}