/* Jan24c.cpp Dave Klick CIS 150 2017-01-24 In-class Demo Demonstrates output formatting. */ #include #include using namespace std; int main() { // declare variables double n1, n2, n3; double avg; // get 3 numbers from user cout << "Enter number 1: "; cin >> n1; cout << "Enter number 2: "; cin >> n2; cout << "Enter number 3: "; cin >> n3; // calculate average avg = (n1 + n2 + n3) / 3.0; // display numbers and average cout << "The numbers:\n"; cout << fixed << showpoint << setprecision(2); cout << setw(7) << n1 << '\n'; cout << setw(7) << n2 << '\n'; cout << setw(7) << n3 << '\n'; cout << "Average to " << setw(7) << avg << endl; // pause cin.ignore(); cout << "Press Enter to continue..."; cin.get(); return 0; }