// Musa Ahmed musa.ahmed@oit.edu #include #include #include #include #include #include #include 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; }