diff options
| author | Musa Ahmed <[email protected]> | 2022-10-26 17:25:52 -0700 |
|---|---|---|
| committer | Musa Ahmed <[email protected]> | 2022-10-26 17:25:52 -0700 |
| commit | 531573350bbc73456f9469ea38db4f727f7f444c (patch) | |
| tree | fb249d4c4e636f20b63464f0fb4d1f63a2603d45 /CST116-Ch5-Debugging/Part2.cpp | |
| parent | decimal places (diff) | |
| download | cst116-proj1-main.tar.xz cst116-proj1-main.zip | |
Diffstat (limited to 'CST116-Ch5-Debugging/Part2.cpp')
| -rw-r--r-- | CST116-Ch5-Debugging/Part2.cpp | 134 |
1 files changed, 134 insertions, 0 deletions
diff --git a/CST116-Ch5-Debugging/Part2.cpp b/CST116-Ch5-Debugging/Part2.cpp new file mode 100644 index 0000000..2796a5c --- /dev/null +++ b/CST116-Ch5-Debugging/Part2.cpp @@ -0,0 +1,134 @@ + +// Musa Ahmed [email protected] + +#include <iostream> +#include <iomanip> +#include <string> +#include <list> +#include <bitset> +#include <vector> +#include <math.h> + + +using std::cout; +using std::ios; +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 income floats + float c1; + float c2; + float c3; + float c4; + + // All the age ints + int a1; + int a2; + int a3; + int a4; + + // spacer for all values on table + int spacer; + + + // Ask user for first input + cout << "Enter a Name: " << endl; + cin >> n1; + cout << "Enter a Age: " << endl; + cin >> a1; + cout << "Enter an Income: " << endl; + cin >> c1; + + + // Ask user for second input + cout << "Enter a Name: " << endl; + cin >> n2; + cout << "Enter a Age: " << endl; + cin >> a2; + cout << "Enter an Income: " << endl; + cin >> c2; + + + // Ask user for third input + cout << "Enter a Name: " << endl; + cin >> n3; + cout << "Enter a Age: " << endl; + cin >> a3; + cout << "Enter an Income: " << endl; + cin >> c3; + + + // Aks user for fourth input + cout << "Enter a Name: " << endl; + cin >> n4; + cout << "Enter a Age: " << endl; + cin >> a4; + cout << "Enter an Income: " << endl; + cin >> c4; + + + // PART 2 + +// 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.setf(ios::left); + cout.width(spacer); + cout << "Name"; + cout.width(spacer); + cout << "Age"; + cout.width(spacer); + cout << "Income" << endl; + cout.precision(3); + + // Display the first profile + cout.width(spacer); + cout << n1; + cout.width(spacer); + cout.precision(3); + cout << a1; + cout.width(spacer); + cout << c1 << endl; + + // Display the first profile + cout.width(spacer); + cout << n2; + cout.width(spacer); + cout.precision(3); + cout << a2; + cout.width(spacer); + cout << c2 << endl; + + // Display the first profile + cout.width(spacer); + cout << n3; + cout.width(spacer); + cout.precision(3); + cout << a3; + cout.width(spacer); + cout << c3 << endl; + + // Display the first profile + cout.width(spacer); + cout << n4; + cout.width(spacer); + cout.precision(3); + cout << a4; + cout.width(spacer); + cout << c4 << endl; + + + return 0; +}
\ No newline at end of file |