From dece0536d375ad7155f0c7c9596e7b8a5de49022 Mon Sep 17 00:00:00 2001 From: "ansari.rayyan@outlook.com" Date: Tue, 19 Oct 2021 23:29:47 -0700 Subject: UPDATED LAB3 ANSWERS --- CST116F2021-Lab3/CST116F2021-Lab3.cpp | 39 ++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 17 deletions(-) (limited to 'CST116F2021-Lab3/CST116F2021-Lab3.cpp') diff --git a/CST116F2021-Lab3/CST116F2021-Lab3.cpp b/CST116F2021-Lab3/CST116F2021-Lab3.cpp index 73af6ad..de2eaba 100644 --- a/CST116F2021-Lab3/CST116F2021-Lab3.cpp +++ b/CST116F2021-Lab3/CST116F2021-Lab3.cpp @@ -6,35 +6,40 @@ using namespace std; int main() { - int fib = 1; - int temp1 = 1; - int temp2 = 0; - int MAX; + int numAssignments; + int avgNum = 0; + int Assignment; - cout << "Enter MAX Fibbonachi number: "; - cin >> MAX; + cout << "Please enter the number of assignments in the class: "; + cin >> numAssignments; - if (MAX != 0) { - cout << fib << endl; - } - else { + if (numAssignments > 0) { + + for (int i = 0; i < numAssignments; i++) { + cout << "Please enter assignment score: "; + cin >> Assignment; + avgNum += Assignment; - cout << "0 WAS ENTERED. ENTER A DIFFERENT NUMBER FOR A SEQUENCE."; + + } + cout << endl; + cout << "The average of the assignments is: "; + cout << (float)avgNum / numAssignments; } - while (fib < MAX) - { - cout << fib << endl; - temp2 = fib; - fib = fib + temp1; - temp1 = temp2; + else { + + cout << "Insufficient number of assignments"; } + } + + //int a = 0; //cout << a++ << endl; //cout << ++a << endl; -- cgit v1.2.3