blob: 86396b4c06aa1751f17bc93e2689d35c6ca31748 (
plain) (
blame)
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
105
106
107
108
109
110
111
112
|
#include <iostream>
#include <iomanip>
#include <string>
#include <list>
#include <bitset>
#include <vector>
#include <math.h>
using namespace std;
using std::cout;
using std::cin;
using std::endl;
using std::string;
using std::to_string;
int main()
{
// All the name strings
string n1;
string n2;
string n3;
string n4;
// All the gpa floats
float g1;
float g2;
float g3;
float g4;
// all the income ints
int c1;
int c2;
int c3;
int c4;
// spacer for all values on table
int spacer;
// Ask user for first input
cout << "Enter a Name: " << endl;
cin >> n1;
cout << "Enter a GPA: " << endl;
cin >> g1;
cout << "Enter an Income: " << endl;
cin >> c1;
// Ask user for second input
cout << "Enter a Name: " << endl;
cin >> n2;
cout << "Enter a GPA: " << endl;
cin >> g2;
cout << "Enter an Income: " << endl;
cin >> c2;
// Ask user for third input
cout << "Enter a Name: " << endl;
cin >> n3;
cout << "Enter a GPA: " << endl;
cin >> g3;
cout << "Enter an Income: " << endl;
cin >> c3;
// Aks user for fourth input
cout << "Enter a Name: " << endl;
cin >> n4;
cout << "Enter a GPA: " << endl;
cin >> g4;
cout << "Enter an Income: " << endl;
cin >> c4;
// Average all the lengths of the names and use this as the spacer
spacer = (n1.size() + n2.size() + n3.size() + n4.size()) / 4 + 5;
// Display the headers of the table
cout << left << setw(spacer) << "Name"
<< left << setw(spacer) << "GPA"
<< left << setw(spacer) << "Income"
<< endl;
// Display the first profile
cout << left << setw(spacer) << n1 << " "
<< left << setw(spacer) << g1
<< left << setw(spacer) << c1
<< endl;
// Display the second profile
cout << left << setw(spacer) << n2 << " "
<< left << setw(spacer) << g2
<< left << setw(spacer) << c2
<< endl;
// Display the third profile
cout << left << setw(spacer) << n3 << " "
<< left << setw(spacer) << g3
<< left << setw(spacer) << c3
<< endl;
// Display the fourth profile
cout << left << setw(spacer) << n4 << " "
<< left << setw(spacer) << g4
<< left << setw(spacer) << c4
<< endl;
return 0;
}
|