aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Ten Eyck <[email protected]>2021-10-19 21:15:42 -0700
committerJoseph Ten Eyck <[email protected]>2021-10-19 21:15:42 -0700
commitde730bdaa56390e27feaa0a1d53aaa63ae1f7db1 (patch)
tree7707a2efc7effda6163f44980c57bac0b611f522
parentAdd online IDE url (diff)
downloadcst116-lab3-josephteneyck-de730bdaa56390e27feaa0a1d53aaa63ae1f7db1.tar.xz
cst116-lab3-josephteneyck-de730bdaa56390e27feaa0a1d53aaa63ae1f7db1.zip
Lab 3 Homework. Some problems are in the .doc file. Most code is in the .cpp file. Successful runs are in the .txt file.HEADmaster
-rw-r--r--CST116F2021-Lab3/CST116F2021-Lab3.cpp20
-rw-r--r--CST116F2021-Lab3/CST116F2021-Lab3.vcxproj2
-rw-r--r--CST116F2021-Lab3/CST116F2021-Lab3.vcxproj.filters2
-rw-r--r--CST116F2021-Lab3/Joseph Ten Eyck-Lab3.cpp312
-rw-r--r--CST116_ Lab 3.docxbin0 -> 96494 bytes
-rw-r--r--TextFile1.txt277
6 files changed, 591 insertions, 22 deletions
diff --git a/CST116F2021-Lab3/CST116F2021-Lab3.cpp b/CST116F2021-Lab3/CST116F2021-Lab3.cpp
deleted file mode 100644
index 41af613..0000000
--- a/CST116F2021-Lab3/CST116F2021-Lab3.cpp
+++ /dev/null
@@ -1,20 +0,0 @@
-// CST116F2021-Lab3.cpp : This file contains the 'main' function. Program execution begins and ends there.
-//
-
-#include <iostream>
-
-int main()
-{
- std::cout << "Hello World!\n";
-}
-
-// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
-// Debug program: F5 or Debug > Start Debugging menu
-
-// Tips for Getting Started:
-// 1. Use the Solution Explorer window to add/manage files
-// 2. Use the Team Explorer window to connect to source control
-// 3. Use the Output window to see build output and other messages
-// 4. Use the Error List window to view errors
-// 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
-// 6. In the future, to open this project again, go to File > Open > Project and select the .sln file
diff --git a/CST116F2021-Lab3/CST116F2021-Lab3.vcxproj b/CST116F2021-Lab3/CST116F2021-Lab3.vcxproj
index a706d70..c7035d7 100644
--- a/CST116F2021-Lab3/CST116F2021-Lab3.vcxproj
+++ b/CST116F2021-Lab3/CST116F2021-Lab3.vcxproj
@@ -139,7 +139,7 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
- <ClCompile Include="CST116F2021-Lab3.cpp" />
+ <ClCompile Include="Joseph Ten Eyck-Lab3.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
diff --git a/CST116F2021-Lab3/CST116F2021-Lab3.vcxproj.filters b/CST116F2021-Lab3/CST116F2021-Lab3.vcxproj.filters
index 1a7ae88..617df37 100644
--- a/CST116F2021-Lab3/CST116F2021-Lab3.vcxproj.filters
+++ b/CST116F2021-Lab3/CST116F2021-Lab3.vcxproj.filters
@@ -15,7 +15,7 @@
</Filter>
</ItemGroup>
<ItemGroup>
- <ClCompile Include="CST116F2021-Lab3.cpp">
+ <ClCompile Include="Joseph Ten Eyck-Lab3.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
diff --git a/CST116F2021-Lab3/Joseph Ten Eyck-Lab3.cpp b/CST116F2021-Lab3/Joseph Ten Eyck-Lab3.cpp
new file mode 100644
index 0000000..3830faf
--- /dev/null
+++ b/CST116F2021-Lab3/Joseph Ten Eyck-Lab3.cpp
@@ -0,0 +1,312 @@
+//======================================================
+//= CODE FOR PROBLEM #1 ON PAGE 161 IS BELOW =
+//======================================================
+//
+//#include <iostream> <iomanip>
+//
+//using std::cout;
+//using std::cin;
+//using std::endl;
+//
+//int main()
+//{
+// short choice;
+//
+// cout << "\t\t\tStudent Grade Program";
+// cout << "\n\t\t\t - Main Menu -";
+// cout << "\n\n\t\t1. Enter Name";
+// cout << "\n\t\t2. Enter test scores";
+// cout << "\n\t\t3. Display test scores";
+// cout << "\n\t\t9. Exit";
+// cout << "\n\n\tPlease enter your choice from the list above: ";
+//
+// cin >> choice;
+//
+// switch (choice)
+// {
+// case 1:
+// cout << "\n\tYou chose: Enter name" << endl;
+// break;
+// case 2:
+// cout << "\n\tYou chose: Enter test scores" << endl;
+// break;
+// case 3:
+// cout << "\n\tYou chose: Display test scores" << endl;
+// break;
+// case 9:
+// cout << "\n\tYou chose: Exit" << endl;
+// break;
+// default:
+// cout << "\n\tMenu choice does not exist" << endl;
+//
+// }
+//
+// return 0;
+//}
+
+
+//======================================================
+//= CODE FOR PROBLEM #2 ON PAGE 168 IS BELOW =
+//======================================================
+
+//#include <iostream>
+//
+//using std::cout;
+//using std::cin;
+//using std::endl;
+//
+//int main()
+//{
+//
+// float rate,
+// loan_amount,
+// interest_amount,
+// interest_and_fees,
+// total_cost;
+//
+// short fee = 0;
+//
+//
+// cout << "\t\t =========================\n";
+// cout << "\t\t\t= Loan Calculator =";
+// cout << "\n\t\t =========================\n";
+//
+// cout << "\n\n\t\tEnter loan amount: ";
+// cin >> loan_amount;
+//
+// cout << "\n\t\tEnter loan rate percent: ";
+// cin >> rate;
+//
+//
+// if (rate < 1 || rate > 18)
+// {
+// cout << "\n\n\tERROR: Interest rate is not between 1% and 18%" << endl;
+// }
+//
+// else if (loan_amount < 100 || loan_amount > 1000)
+// {
+// cout << "\n\n\tERROR: Loan amount is not between $100 and $1,000" << endl;
+// }
+//
+// else
+// {
+//
+// if (loan_amount <= 500)
+// fee = 20;
+//
+// else
+// fee = 25;
+//
+//
+// interest_amount = loan_amount * rate * 0.01;
+//
+// interest_and_fees = interest_amount + fee;
+//
+// total_cost = loan_amount + interest_and_fees;
+//
+//
+// cout << "\n\n\tRequested loan amount: $" << loan_amount;
+// cout << "\n\tInterest rate: " << rate << "%";
+// cout << "\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
+// cout << "\n\tInterest amount: $" << interest_amount;
+// cout << "\n\tFee: $" << fee;
+// cout << "\n\n\tSum of interst and fees: $" << interest_and_fees;
+// cout << "\n\n================================================================";
+// cout << "\n\tTotal Cost: $" << total_cost << "\n\n";
+// }
+//
+//
+// return 0;
+//}
+
+
+//======================================================
+//= CODE FOR PROBLEM #1 ON PAGE 177 IS BELOW =
+//======================================================
+
+//#include <iostream>
+//
+//using std::cout;
+//using std::cin;
+//using std::endl;
+//
+//int main()
+//{
+//
+// int number = 0;
+//
+// cout << "\n\tEnter an integer between 1 and 50: ";
+// cin >> number;
+//
+// cout << "\n";
+//
+// if (number < 1 || number > 50)
+// cout << "\nERROR: Number must be between 1 and 50\n\n";
+//
+// else
+// {
+// cout << number << " ";
+//
+// while (number > 0)
+// {
+// --number;
+//
+// if (number % 2 == 0)
+// cout << number << " ";
+//
+// else
+// cout << " ";
+//
+// }
+// cout << "\n\n" << endl;
+// }
+//
+// return 0;
+//}
+
+
+//======================================================
+//= CODE FOR PROBLEM #1 ON PAGE 179 IS BELOW =
+//======================================================
+
+//#include <iostream>
+//
+//using std::cout;
+//using std::cin;
+//using std::endl;
+//
+//int main()
+//{
+// int number = 0;
+//
+// cout << "\n\tEnter an integer between 1 and 50: ";
+// cin >> number;
+//
+// cout << "\n";
+//
+//
+// do
+// if (number < 1 || number > 50)
+// {
+// cout << "\n\nERROR: Number must be between 1 and 50\n";
+//
+// cout << "\n\tEnter an integer betwen 1 and 50: ";
+// cin >> number;
+//
+// cout << "\n";
+// }
+// else
+// cout << "\n\n";
+// while (number < 1 || number > 50);
+//
+//
+// cout << number << " ";
+//
+// while (number > 0)
+// {
+// --number;
+//
+// if (number % 2 == 0)
+// cout << number << " ";
+//
+// else
+// cout << " ";
+//
+// }
+// cout << "\n\n" << endl;
+//
+// return 0;
+//}
+
+
+//======================================================
+//= CODE FOR PROBLEM #1 ON PAGE 184 IS BELOW =
+//======================================================
+
+//#include <iostream>
+//
+//using std::cout;
+//using std::cin;
+//using std::endl;
+//
+//int main()
+//{
+//
+// int assignments = 0;
+// int assignments_initial = 0;
+// int sum = 0;
+//
+// cout << "\n\t\tEnter number of assignments: ";
+// cin >> assignments;
+//
+// assignments_initial = assignments;
+//
+// cout << "\n\n";
+//
+// for (assignments; assignments > 0; assignments--)
+// {
+// int score = 0;
+//
+// cout << "\tEnter assignment " << assignments << " score: ";
+// cin >> score;
+//
+// cout << "\n";
+//
+// sum += score;
+// }
+//
+// float avg = (float)sum / (float)assignments_initial;
+//
+// cout << "\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n";
+// cout << "\n\t\tAverage assignment score: " << avg;
+// cout << "\n\n" << endl;
+//
+// return 0;
+//}
+
+
+//======================================================
+//= CODE FOR PROBLEM #3 ON PAGE 192 IS BELOW =
+//======================================================
+
+//#include <iostream>
+//
+//using std::cout;
+//using std::cin;
+//using std::endl;
+//
+//int main()
+//{
+// int ending_number = 0;
+// int current_number = 1;
+// int previous_number = 0;
+// int hold = 0;
+//
+// cout << "\n\t\t==================================";
+// cout << "\n\t\t== Fibonacci sequence generator ==";
+// cout << "\n\t\t==================================";
+// cout << "\n\n\t";
+//
+// cout << "Enter ending number: ";
+// cin >> ending_number;
+//
+// cout << "\n\n";
+//
+// if (ending_number < 1)
+// cout << "ERROR: Ending number must be 1 or greater";
+//
+// else
+//
+// while (current_number <= ending_number)
+// {
+// cout << current_number << " ";
+//
+// hold = current_number;
+// current_number += previous_number;
+// previous_number = hold;
+// }
+//
+// cout << endl;
+//
+// return 0;
+//} \ No newline at end of file
diff --git a/CST116_ Lab 3.docx b/CST116_ Lab 3.docx
new file mode 100644
index 0000000..b16cd69
--- /dev/null
+++ b/CST116_ Lab 3.docx
Binary files differ
diff --git a/TextFile1.txt b/TextFile1.txt
new file mode 100644
index 0000000..a2ea484
--- /dev/null
+++ b/TextFile1.txt
@@ -0,0 +1,277 @@
+========================================
+ SUCCESSFUL CODE RUNS ARE SHOWN BELOW
+========================================
+
+
+
+======================================================
+= RUNS FOR PROBLEM #1 ON PAGE 161 ARE BELOW =
+======================================================
+
+
+ Student Grade Program
+ - Main Menu -
+
+ 1. Enter Name
+ 2. Enter test scores
+ 3. Display test scores
+ 9. Exit
+
+ Please enter your choice from the list above: 2
+
+ You chose: Enter test scores
+
+C:\Users\eclip\source\repos\cst116-lab3-JosephTenEyck\x64\Debug\CST116F2021-Lab3.exe (process 15276) 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 . . .
+
+
+
+ Student Grade Program
+ - Main Menu -
+
+ 1. Enter Name
+ 2. Enter test scores
+ 3. Display test scores
+ 9. Exit
+
+ Please enter your choice from the list above: 5
+
+ Menu choice does not exist
+
+C:\Users\eclip\source\repos\cst116-lab3-JosephTenEyck\x64\Debug\CST116F2021-Lab3.exe (process 14464) 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 . . .
+
+
+
+
+======================================================
+= RUNS FOR PROBLEM #2 ON PAGE 168 ARE BELOW =
+======================================================
+
+
+ =========================
+ = Loan Calculator =
+ =========================
+
+
+ Enter loan amount: 630
+
+ Enter loan rate percent: 13
+
+
+ Requested loan amount: $630
+ Interest rate: 13%
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ Interest amount: $81.9
+ Fee: $25
+
+ Sum of interst and fees: $106.9
+
+================================================================
+ Total Cost: $736.9
+
+
+C:\Users\eclip\source\repos\cst116-lab3-JosephTenEyck\x64\Debug\CST116F2021-Lab3.exe (process 17108) 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 . . .
+
+
+
+
+ =========================
+ = Loan Calculator =
+ =========================
+
+
+ Enter loan amount: 1200
+
+ Enter loan rate percent: 15
+
+
+ ERROR: Loan amount is not between $100 and $1,000
+
+C:\Users\eclip\source\repos\cst116-lab3-JosephTenEyck\x64\Debug\CST116F2021-Lab3.exe (process 1188) 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 . . .
+
+
+
+
+ =========================
+ = Loan Calculator =
+ =========================
+
+
+ Enter loan amount: 450
+
+ Enter loan rate percent: 20
+
+
+ ERROR: Interest rate is not between 1% and 18%
+
+C:\Users\eclip\source\repos\cst116-lab3-JosephTenEyck\x64\Debug\CST116F2021-Lab3.exe (process 15324) 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 . . .
+
+
+
+
+
+
+======================================================
+= RUNS FOR PROBLEM #1 ON PAGE 177 ARE BELOW =
+======================================================
+
+
+ Enter an integer between 1 and 50: 45
+
+45 44 42 40 38 36 34 32 30 28 26 24 22 20 18 16 14 12 10 8 6 4 2 0
+
+
+C:\Users\eclip\source\repos\cst116-lab3-JosephTenEyck\x64\Debug\CST116F2021-Lab3.exe (process 21588) 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 . . .
+
+
+
+
+
+ Enter an integer between 1 and 50: 36
+
+36 34 32 30 28 26 24 22 20 18 16 14 12 10 8 6 4 2 0
+
+
+C:\Users\eclip\source\repos\cst116-lab3-JosephTenEyck\x64\Debug\CST116F2021-Lab3.exe (process 22184) 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 . . .
+
+
+======================================================
+= RUNS FOR PROBLEM #1 ON PAGE 179 ARE BELOW =
+======================================================
+
+
+
+ Enter an integer between 1 and 50: 23
+
+
+
+23 22 20 18 16 14 12 10 8 6 4 2 0
+
+
+
+C:\Users\eclip\source\repos\cst116-lab3-JosephTenEyck\x64\Debug\CST116F2021-Lab3.exe (process 20572) 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 . . .
+
+
+
+
+
+ Enter an integer between 1 and 50: 51
+
+
+
+ERROR: Number must be between 1 and 50
+
+ Enter an integer betwen 1 and 50: 0
+
+
+
+ERROR: Number must be between 1 and 50
+
+ Enter an integer betwen 1 and 50: 27
+
+27 26 24 22 20 18 16 14 12 10 8 6 4 2 0
+
+
+
+C:\Users\eclip\source\repos\cst116-lab3-JosephTenEyck\x64\Debug\CST116F2021-Lab3.exe (process 21600) 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 . . .
+
+
+
+======================================================
+= RUN FOR PROBLEM #1 ON PAGE 184 IS BELOW =
+======================================================
+
+
+
+ Enter number of assignments: 5
+
+
+ Enter assignment 5 score: 15
+
+ Enter assignment 4 score: 18
+
+ Enter assignment 3 score: 20
+
+ Enter assignment 2 score: 16
+
+ Enter assignment 1 score: 19
+
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+ Average assignment score: 17.6
+
+
+C:\Users\eclip\source\repos\cst116-lab3-JosephTenEyck\x64\Debug\CST116F2021-Lab3.exe (process 9384) 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 . . .
+
+
+======================================================
+= RUNS FOR PROBLEM #3 ON PAGE 192 ARE BELOW =
+======================================================
+
+
+
+ ==================================
+ == Fibonacci sequence generator ==
+ ==================================
+
+ Enter ending number: 99
+
+
+1 1 2 3 5 8 13 21 34 55 89
+
+C:\Users\eclip\source\repos\cst116-lab3-JosephTenEyck\x64\Debug\CST116F2021-Lab3.exe (process 4380) 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 . . .
+
+
+
+
+
+ ==================================
+ == Fibonacci sequence generator ==
+ ==================================
+
+ Enter ending number: 55
+
+
+1 1 2 3 5 8 13 21 34 55
+
+C:\Users\eclip\source\repos\cst116-lab3-JosephTenEyck\x64\Debug\CST116F2021-Lab3.exe (process 24500) 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 . . .
+
+
+
+
+ ==================================
+ == Fibonacci sequence generator ==
+ ==================================
+
+ Enter ending number: 0
+
+
+ERROR: Ending number must be 1 or greater
+
+C:\Users\eclip\source\repos\cst116-lab3-JosephTenEyck\x64\Debug\CST116F2021-Lab3.exe (process 21604) 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 . . .