aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraustinsworld15 <[email protected]>2021-10-13 14:32:27 -0700
committerGitHub <[email protected]>2021-10-13 14:32:27 -0700
commit255866e29ab366e45b937fa8d689f121d977b6cc (patch)
tree1f89f40fe45366001361fa9d35ecd8b9b1b8277e
parentAdd online IDE url (diff)
downloadcst116-lab2-austinsworld15-master.tar.xz
cst116-lab2-austinsworld15-master.zip
-rw-r--r--Lab 2197
1 files changed, 197 insertions, 0 deletions
diff --git a/Lab 2 b/Lab 2
new file mode 100644
index 0000000..dbbc8d4
--- /dev/null
+++ b/Lab 2
@@ -0,0 +1,197 @@
+CST116
+Module 2: Lab 2
+
+3a 4.1 #1 - 7
+
+1. Legal – Numeric Literal
+2. Illegal
+3. Legal – String literal
+4. Illegal
+5. Illegal
+6. Illegal
+7. Illegal
+
+4.3 #3
+
+a.There should only be one “int” and it should be at the beginning(i.e. int a, b;)
+b.a can’t be signified as another variable(b) because b is not signified first
+(i.e.b = 0; a = b;)
+c.b should be declared on a different line(i.e. int a = 0; int b = 3.5;)
+d.Instead of quotations, it should be an apostrophe(ex. char grade = ‘A’;)
+e.Instead of char it should be int because char uses a string of letters(ex. int c = 1;)
+f.
+g.Should not be a string, should be a character, also use apostrophe
+(ex. char x = ‘T’;)
+
+6.1 #1 - 4
+
+1. Invalid.Should be ‘y = 5 * x + 1; ’
+2. Invalid.Should be ‘x * x + 2 * x + 1 = 0; ’
+3. Valid
+4. Invalid.There cannot be a 0 starting the expression
+
+3b 4.12 #1 - 2
+
+1. He did the math wrong.Change .06 with 1.06
+2. The class score doesn’t add up to 100 % (.2 + .4 + .25 = .85)
+
+3c 4.13 #2 - 3
+
+2. #include <iostream>
+Using std::cout
+
+Int main()
+{
+ Char ascii = 67;
+
+ Cout << ascii << ‘\n’;
+
+ Ascii = 43;
+ Cout << ascii << ‘\n’;
+ Cout << ascii << ‘\n’;
+
+ Return 0;
+}
+ 3. #include <stdio.h>
+
+ int main()
+ {
+ int age_of_person;
+ float year = 365, days;
+ //ask for age
+ printf("\nHow old are you: ");
+ //process age
+ scanf_s(" %d", &age_of_person);
+
+ //convert years into days
+ days = age_of_person * year;
+ //print answer
+ printf("\nYour age in days is: %f", days);
+
+ return 0;
+
+ 4a 5.4 #1
+
+ 1.
+#include <iostream>
+#include <stdlib.h>
+#include <iomanip>
+
+ float temperature;
+
+ using namespace std;
+ int main()
+ {
+
+ //taking temperature and storing
+ printf("\nWhat is your temperature? ");
+ cin >> temperature;
+
+
+ //listing temperature
+
+ cout << "\nYour Temperature is: ";
+
+ cout.setf(ios::fixed);
+ cout << setprecision(6);
+ cout << temperature << endl;
+
+ return 0;
+ }
+
+ 6.3 #1 - 7
+
+ 1. 25
+ 2. 30
+ 3. error ? a is already defined
+ corrected is a = 5
+ b = a + ( 5 + 10 ) * 2;
+ 4. 0
+ 5. 1
+ 6. error ? both operands have to be an integer
+ corrected is a = 5 % 2;
+ 7. 4
+
+ 4b 5.9
+
+ 1.
+#include <iostream>
+#include<iomanip>
+
+ using std::cout;
+ using std::cin;
+ using std::endl;
+
+
+ int main()
+ {
+
+ float money = 123.45F;
+ float raise;
+
+ cout << "you have $";
+ cout << money << endl;
+
+ //breakpoint 1
+ //put a breakpoint on the following line
+ cout << "enter percent raise: ";
+ cin >> raise;
+
+ money = money * raise;
+
+ cout << "After your raise you have $";
+ cout << money << endl;
+
+ return 0;
+ }
+
+ 5.10 #1
+
+ 1.
+#include <iostream>
+ using std::cout;
+ using std::cin;
+ using std::endl;
+
+ int main()
+ {
+ double ProductionHours;
+ double PreProductionHours;
+ double ProducersHours;
+ double ProductionCost;
+ double PreProductionCost;
+ double ProducersCost;
+ double TotalCost;
+ double PRODUCTIONRATE{};
+ double PRE_PRODUCTION_RATE{};
+ double PRODUCERS_RATE{};
+ double ProducerHours{};
+
+ cout << "Enter Production Hours: ";
+ cin >> ProductionHours;
+ cout << "\nEnter Pre-Production Hours: ";
+ cin >> PreProductionHours;
+ cout << "\nEnter Producers Hours: ";
+ cin >> ProducersHours;
+
+ ProductionCost = ProductionHours * PRODUCTIONRATE;
+ PreProductionCost = PreProductionHours * PRE_PRODUCTION_RATE;
+ ProducersCost = ProducerHours * PRODUCERS_RATE;
+
+ TotalCost = ProductionCost + PreProductionCost + ProducersCost;
+
+ cout << "\n\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;
+ }