Server IP : 172.16.15.8 / Your IP : 3.145.102.18 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/mpcollins/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
/* File Name: hw3.cpp Author: Michael Collins Instructor: Dr. John Wang Compilation: g++ hw3.cpp -o hw3.out Execution: ./hw3.out Goal: This program will add, subtract, multiply, and divide two numbers input by the user. */ #include <iostream> #include <iomanip> using namespace std; int main() { float a, b, add, sub, mult, div; cout << fixed << showpoint << setprecision (1); string line = "------------------------------"; cout << line; cout << "\nInput the first number(-1 to quit): "; cin >> a; while (a > 0) { cout << "\nInput the second number: "; cin >> b; add = a + b; sub = a - b; mult = a * b; div = a / b; cout << "\nThe addition of the two numbers is: " << add << endl; cout << "\nThe subtraction of the two numbers is: " << sub << endl; cout << "\nThe multiplication of the two numbers is: " << mult << endl; cout << "\nThe division of the two numbers is: " << div << endl; cout << line; cout << "\nInput the first number(-1 to quit): "; cin >> a; } return 0; }