aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author[email protected] <[email protected]>2021-10-12 21:05:37 -0700
committer[email protected] <[email protected]>2021-10-12 21:05:37 -0700
commit56948eb45177fcf1a44677dd54190daa0cb0bcdf (patch)
tree24c5c51ea3d297f6baae2d33c18a0697a0351d58
parentContains Exercises from Lab2 document on canvas (diff)
downloadcst116-lab2-rayyanansari03-56948eb45177fcf1a44677dd54190daa0cb0bcdf.tar.xz
cst116-lab2-rayyanansari03-56948eb45177fcf1a44677dd54190daa0cb0bcdf.zip
Lab2 Assignment
-rw-r--r--Lab2Ansari/Lab2Ansari.cpp63
-rw-r--r--Lab2Ansari/Lab2answeres-Ansari.txt304
2 files changed, 359 insertions, 8 deletions
diff --git a/Lab2Ansari/Lab2Ansari.cpp b/Lab2Ansari/Lab2Ansari.cpp
index ae9f700..9fe9a00 100644
--- a/Lab2Ansari/Lab2Ansari.cpp
+++ b/Lab2Ansari/Lab2Ansari.cpp
@@ -2,17 +2,64 @@
//
#include <iostream>
-#include <iomanip>
-using namespace std;
-using std::ios;
-
-
-int main() {
+using namespace std;
+int main()
+{
+ double ProductionHours,
+ PreProductionHours,
+ ProducersHours,
+ ProductionCost,
+ PreProductionCost,
+ ProducersCost,
+ TotalCost,
+ PRODUCTION_RATE,
+ PRE_PRODUCTION_RATE,
+ PRODUCERS_RATE;
+
+
+ cout << "Enter Production Hours: ";
+
+ cin >> ProductionHours;
+
+ cout << "\nEnter Pre-Production Hours:";
+ cin >> PreProductionHours;
+
+ cout << "\nEnter Producers Hours: ";
+ cin >> ProducersHours;
+
+ cout << "\nEnter Production Rate: ";
+ cin >> PRODUCTION_RATE;
+
+ cout << "\nEnter Pre Production Rate: ";
+ cin >> PRE_PRODUCTION_RATE;
+
+ cout << "\nEnter Producers Rate: ";
+ cin >> PRODUCERS_RATE;
+
+ ProductionCost = ProductionHours * PRODUCTION_RATE;
+ PreProductionCost = PreProductionHours * PRE_PRODUCTION_RATE;
+ ProducersCost = ProducersHours * PRODUCERS_RATE;
+
+ TotalCost = ProductionCost + PreProductionCost + ProducersCost;
+
+ cout << "\n\t\tCar Dealership Bill\n\"";
+ cout << "\n\nProduction Cost: ";
+ cout << ProductionCost;
+
+ cout << "\n\nPre-Production Cost: ";
+ cout << PreProductionCost;
+
+ cout << "\n\nProducers Cost: ";
+ cout << ProducersCost;
+
+ cout << "\n\nWeekly Total Cost: ";
+ cout << TotalCost << endl;
+
+ return 0;
+}
-
- }
/*
* 112-115 5.9 #5
diff --git a/Lab2Ansari/Lab2answeres-Ansari.txt b/Lab2Ansari/Lab2answeres-Ansari.txt
new file mode 100644
index 0000000..13f35d9
--- /dev/null
+++ b/Lab2Ansari/Lab2answeres-Ansari.txt
@@ -0,0 +1,304 @@
+EXERCISES 3a
+
+Page 63-64;Exercises 4.1
+
+1)-12.34 - foat
+2)"Hello" - string
+3)"F" or 'F' - string or char
+4)"1234" - string
+5)'1' - char
+6)"A" or 'A' - string or char
+7)"Marcus" - string
+
+3 (page 72))
+a)int a,b;
+b)int b = 0;
+int a = b;
+c.int a = 0;
+float b = 3.5;
+d.char grade = 'A';
+e.char c = 1; or char = '1'; Im not sure is the book is okay with keeping the value 1 or they want what 1 is referring to.
+f.int a, b, c, d, e , f;
+g.string x = "This is a test.";
+
+4(page 122)) - I am solving these problems assuming the variables already have been pre defined somewhere in the program.
+a)y = 5*x+1;
+b)C++ does not solve equation by default. Its a polynomial. i dont think there is a way to rewrite it and have the computer
+read it without the help of a library
+c)x = 5*a+4;
+d.b = 0/-15;
+--------------------------------------------------------------------------
+EXERCISES 3b
+
+Page 82,83 # 1-2
+
+1)
+Display "Enter old wage: "
+Read Old_wage
+New_wage = Old_wage*1.06
+Display Old_wage
+Display"+6%="
+Display New_wage
+
+2)
+Display "Enter assignment average:"
+Read Assignment_avg
+
+Display "Enter test 1:"
+Read Test 1
+
+Display "Enter test 2:"
+Read Test2
+
+Display "Enter test 3:"
+Read Test3
+
+Display "Enter Final:"
+Read Final
+
+Test_avg = (Test1 + Test2 + Test3)/3
+Class_score + Assignmnet_avg*.30 + Final*.25 + Test_avg*.45
+
+Display "Final Score:"
+Display Class_score
+
+===============================================================================
+EXERCISE 4a
+
+Page 100 - #1
+
+PROGRAM:
+#include <iostream>
+#include <iomanip>
+using namespace std;
+using std::ios;
+
+int main()
+{
+ float personTemp;
+ cout << "Enter your temperature: " << endl;
+ cin >> personTemp;
+ cout.setf(ios::fixed);
+ cout << setw(6) << setprecision(1) << personTemp << endl;
+
+
+
+}
+
+
+OUTPUT:
+Enter your temperature:
+54.721
+ 54.7
+
+C:\Users\ansar\source\repos\OIT Brushup\Debug\OIT Brushup.exe (process 6536) exited with code 0.
+To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops.
+Press any key to close this window . . .
+
+Page 123-124 #1-5
+
+#include <iostream>
+#include <iomanip>
+using namespace std;
+using std::ios;
+
+int main()
+{
+ float a;
+
+ a = 5 + 10 * 2;
+ cout << a << endl;
+
+ a = (5 + 10) * 2;
+ cout << a << endl;
+
+ a = 5;
+ a = a + (5 + 10) * 2;
+ cout << a << endl;
+
+ a = 10 % 5;
+ cout << a << endl;
+ a = 10 % 3;
+ cout << a << endl;
+
+}
+
+OUTPUT:
+
+25
+30
+35
+0
+1
+
+C:\Users\ansar\source\repos\OIT Brushup\Debug\OIT Brushup.exe (process 17632) exited with code 0.
+To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops.
+Press any key to close this window . . .
+
+
+#5-7
+
+#include <iostream>
+#include <iomanip>
+using namespace std;
+using std::ios;
+
+int main()
+{
+ float a;
+ a = 7 + 5 - 2;
+ cout << a << endl;
+
+ a = 5.2 / 2.3;
+ cout << a;
+
+}
+
+
+OUTPUT:
+
+10
+2.26087
+C:\Users\ansar\source\repos\OIT Brushup\Debug\OIT Brushup.exe (process 21412) exited with code 0.
+To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops.
+Press any key to close this window . . .
+
+--------------------------------------------------------------------------------------
+
+EXERCISE 4b
+
+Page 112-114
+
+PROGRAM:
+
+#include <iostream>
+#include <iomanip>
+using namespace std;
+using std::ios;
+
+int main()
+{
+ float money = 123.45;
+ float raise;
+
+ cout << "You have $";
+ cout << money << endl;
+
+ cout << "enter percent raise: ";
+ cin >> raise;
+ raise = (raise / 100) + 1;
+
+ money = money * raise;
+ cout << "After your raise you have $";
+ cout << money << endl;
+
+}
+
+OUTPUT:
+
+You have $123.45
+enter percent raise: 10
+After your raise you have $135.795
+
+C:\Users\ansar\source\repos\OIT Brushup\Debug\OIT Brushup.exe (process 18136) exited with code 0.
+To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops.
+Press any key to close this window . . .
+
+
+Page 114 - 115
+
+PROGRAM:
+
+#include <iostream>
+
+using namespace std;
+
+int main()
+{
+ double ProductionHours,
+ PreProductionHours,
+ ProducersHours,
+ ProductionCost,
+ PreProductionCost,
+ ProducersCost,
+ TotalCost,
+ PRODUCTION_RATE,
+ PRE_PRODUCTION_RATE,
+ PRODUCERS_RATE;
+
+
+ cout << "Enter Production Hours: ";
+
+ cin >> ProductionHours;
+
+ cout << "\nEnter Pre-Production Hours:";
+ cin >> PreProductionHours;
+
+ cout << "\nEnter Producers Hours: ";
+ cin >> ProducersHours;
+
+ cout << "\nEnter Production Rate: ";
+ cin >> PRODUCTION_RATE;
+
+ cout << "\nEnter Pre Production Rate: ";
+ cin >> PRE_PRODUCTION_RATE;
+
+ cout << "\nEnter Producers Rate: ";
+ cin >> PRODUCERS_RATE;
+
+ ProductionCost = ProductionHours * PRODUCTION_RATE;
+ PreProductionCost = PreProductionHours * PRE_PRODUCTION_RATE;
+ ProducersCost = ProducersHours * PRODUCERS_RATE;
+
+ TotalCost = ProductionCost + PreProductionCost + ProducersCost;
+
+ cout << "\n\t\tCar Dealership Bill\n\"";
+ cout << "\n\nProduction Cost: ";
+ cout << ProductionCost;
+
+ cout << "\n\nPre-Production Cost: ";
+ cout << PreProductionCost;
+
+ cout << "\n\nProducers Cost: ";
+ cout << ProducersCost;
+
+ cout << "\n\nWeekly Total Cost: ";
+ cout << TotalCost << endl;
+
+ return 0;
+}
+
+OUTPUT:
+
+Enter Production Hours: 5
+
+Enter Pre-Production Hours:3
+
+Enter Producers Hours: 7
+
+Enter Production Rate: 8
+
+Enter Pre Production Rate: 1
+
+Enter Producers Rate: 6
+
+ Car Dealership Bill
+"
+
+Production Cost: 40
+
+Pre-Production Cost: 3
+
+Producers Cost: 42
+
+Weekly Total Cost: 85
+
+C:\Users\ansar\Source\Repos\cst116-lab2-rayyanansari03_1\Lab2Ansari\Debug\Lab2Ansari.exe (process 9804) exited with code 0.
+To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops.
+Press any key to close this window . . .
+
+
+
+
+
+