diff options
Diffstat (limited to 'Lab3_Tyler.txt')
| -rw-r--r-- | Lab3_Tyler.txt | 185 |
1 files changed, 185 insertions, 0 deletions
diff --git a/Lab3_Tyler.txt b/Lab3_Tyler.txt new file mode 100644 index 0000000..6a7b2b3 --- /dev/null +++ b/Lab3_Tyler.txt @@ -0,0 +1,185 @@ +Tyler Taormina +cst116 + +Module 3 Lab 3 +--------------------------------------------------------------------------------------------------------------------------------------------------- +5A) + + 6.4 exercises page 126 + #1 submit ouput + + 1) The output for the code provided in the text book would be... + 0 + 2 + 3 + 2 + 1 + + + + + 7.1 exercises page 148 + #1-6 submit corrected conditions + + 1) int_expl >= int_exp2; + 2) int_expl == int_exp2; + 3) int_exp1 != int_exp2; + 4) char_exp == 'A'; + 5) int_exp1 > char_exp; illegal because we are attempting to compare an integer and a character. + 6) int_exp1 < 2 && int_exp1 > -10; + + + 7.2 exercises page 155 + #1 submit code & run + + 1) if (a > 0) + cout << "a is greater than 0" << endl; + +----------------------------------------------------------------------------------------------------------------------------------------------------- +5B) + + 7.4 exercises page 161 + #1 submit code & run + + 1) +#include <iostream> +#include <iomanip> + +using namespace std; + +int main() { + int user_choice; + + cout << "\t\tStudent Grade Program" << endl; + + cout << "\t\t - Main Menu -" << endl; + + + cout << "1. Enter Name" << endl; + cout << "2. Enter test scores" << endl; + cout << "3. Display test scores" << endl; + cout << "9. Exit" << endl; + + cout << "Please enter your choice from the list above: "; + cin >> user_choice; + + switch (user_choice) + { + case 1: + cout << "You chose to Enter your name." << endl; + break; + case 2: + cout << "You chose to Enter test scores." << endl; + break; + case 3: + cout << "You chose to display test scores." << endl; + break; + case 9: + cout << "You chose to exit." << endl; + break; + } + + return 0; +} + + +5C) + + 7.10 exercises page 168 + #2 submit code & run + + 2) + sudo code + ----------------- + intialize loan fee for (little loan) + intialize loan fee for (big loan) + input loan amount + check to make sure if loan amount is within range + input interest rate + check to make sure interest rate is in range + calculate interest + calculate total cost including interest and fee + display interest amount on loan + display requested loan amount + display interest rate + display total cost with interest and fee + + code + --------------------------------------------------------- + +#include <iostream> +#include <iomanip> + +using namespace std; + +int main() +{ + int fee_1 = 20; + int fee_2 = 25; + int loan_amount, interest_rate; + double interest_dec, interest_amount , total_cost = 0; + + + std::cout << "Please enter a loan amount request: "; + cin >> loan_amount; + + if (loan_amount >= 100 && loan_amount <= 1000) + { + std::cout << "Please enter an interest rate: "; + cin >> interest_rate; + if (interest_rate >= 1 && interest_rate <= 18) + { + if (loan_amount > 500) + { + total_cost += fee_2; + } + else + { + total_cost += fee_1; + } + + interest_dec = interest_rate * .01; + interest_amount = interest_dec * loan_amount; + total_cost += interest_amount + loan_amount; + std::cout << "Interest paid on this loan is: $" << interest_amount << endl; + std::cout << "Requested Loan: $" << loan_amount << endl; + std::cout << "Interest rate: " << interest_rate << "%" << endl; + std::cout << "Total cost including all fees for this loan will be: $" << total_cost << endl; + + return 0; + } + else + { + std::cout << "Error. Invalid interest rate. Please enter an interest rate between 1 and 18." << endl; + return 0; + } + + + } + else + { + std::cout << "Error. Invalid loan amount. Please enter a loan amount between $100 and $1000." << endl; + return 0; + } + + + return 0; + +} + + + + + +6A) + 6.5 Exercises + pg 126-127 + #1-5 + + 1.) a += 25; + 2.) b *= 2 * a; + 3.) b++; + 4.) c %= 5; + 5.) b /= a + + 8.2 Pg 177 #1 |