aboutsummaryrefslogtreecommitdiff
path: root/CST116-Ch5-Debugging/Project1.cpp
diff options
context:
space:
mode:
authorMusa Ahmed <[email protected]>2022-10-11 20:14:20 -0700
committerMusa Ahmed <[email protected]>2022-10-11 20:14:20 -0700
commit0ed413563986055efc1484629325f3e553ee9368 (patch)
tree0346aed8a09f49d35f5d55b92541fee8bc48b6f0 /CST116-Ch5-Debugging/Project1.cpp
parentupdated table (diff)
downloadcst116-proj1-0ed413563986055efc1484629325f3e553ee9368.tar.xz
cst116-proj1-0ed413563986055efc1484629325f3e553ee9368.zip
documentation
Diffstat (limited to 'CST116-Ch5-Debugging/Project1.cpp')
-rw-r--r--CST116-Ch5-Debugging/Project1.cpp21
1 files changed, 15 insertions, 6 deletions
diff --git a/CST116-Ch5-Debugging/Project1.cpp b/CST116-Ch5-Debugging/Project1.cpp
index e7fc174..86396b4 100644
--- a/CST116-Ch5-Debugging/Project1.cpp
+++ b/CST116-Ch5-Debugging/Project1.cpp
@@ -16,27 +16,29 @@ 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;
@@ -45,7 +47,7 @@ int main()
cin >> c1;
-
+ // Ask user for second input
cout << "Enter a Name: " << endl;
cin >> n2;
cout << "Enter a GPA: " << endl;
@@ -54,7 +56,7 @@ int main()
cin >> c2;
-
+ // Ask user for third input
cout << "Enter a Name: " << endl;
cin >> n3;
cout << "Enter a GPA: " << endl;
@@ -63,7 +65,7 @@ int main()
cin >> c3;
-
+ // Aks user for fourth input
cout << "Enter a Name: " << endl;
cin >> n4;
cout << "Enter a GPA: " << endl;
@@ -71,28 +73,35 @@ int main()
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