#include using namespace std; //5a //6.4 Exercises //int main() //{ // int a = 0; // cout << a++ << endl; // cout << ++a << endl; // cout << a + 1 << endl; // cout << a << endl; // cout << --a << endl; //} //5a //7.2 Exercises //int main() //{ // int money = 0; // int accounts = 0; // // cout << "What is your balance?" << endl; // cin >> money; // cout << "How many accounts do you have open with us?" << endl; // cin >> accounts; // // if (money >= 25000) // cout << "Your membership is Platinum"; // else if (money < 25000 && money > 10000 && accounts == 2) // cout << "Your membership is Gold"; // else if (money > 10000 && accounts == 1) // cout << "Your membership is Silver"; // else if (money <= 10000) // cout << "Your membership is Copper"; // // return 0; //} //5b //7.4 Exercises //int main() //{ // char menu_selection; // cout << "Student Grade Program" << endl; // cout << "- Main Menu -" << endl << endl; // cout << "1. Enter name\n2. Enter test scores\n3. Display test scores\n9. Exit" // << endl << endl; // cout << "Please enter your choice from the list above "; // // cin >> menu_selection; // // switch (menu_selection) // { // case '1': // cout << "Enter name"; // break; // case '2': // cout << "Enter test scores"; // break; // case '3': // cout << "Display test scores"; // break; // case '9': // cout << "Exit"; // break; // } //} //5c //7.10 Exercises #2 //int main() //{ //variables // int amountOfLoan = 0; // float interestRate = 0; // int fee = 0; //defining variables w/ input sequence // cout << "Enter the amount of your loan" << endl; // cin >> amountOfLoan; // cout << endl; // cout << "Enter the interest rate" << endl; // cin >> interestRate; // cout << endl; //checking if inputs are valid // if (interestRate > 18 || interestRate < 1) // { // cout << "Error: invalid interest rate" << endl; // return 0; // } // if (amountOfLoan > 1000 || amountOfLoan < 100) // { // cout << "Error: invalid loan amount" << endl; // return 0; // } //calculating fees // if (amountOfLoan <= 500 || amountOfLoan >= 100) //fee = 20; // if (amountOfLoan > 500) //fee = 25; //outputting data // cout << "The total amount of interest due is "; // cout << amountOfLoan * interestRate << endl; // cout << "The interest rate is "; // cout << interestRate << endl; // cout << "The total amount of interest and fees due is "; // cout << (amountOfLoan * interestRate) + fee << endl; // return 0; // } //6b //Section 8.4 //#1 int main() { //defining variables int numOfAssignments = 0; int gradedAssignments = 0; float score; float scoreAccumulate = 0; float averageScore; int numCount = 1; //user prompt and input cout << "Enter the number of assignments" << endl; cin >> numOfAssignments; gradedAssignments = numOfAssignments; cout << endl; //get each assignment score for (numOfAssignments; numOfAssignments > 0; numOfAssignments--) { cout << "Enter the score for Assignment #" << numCount << endl; cin >> score; scoreAccumulate = scoreAccumulate + score; numCount++; } //calculate average score averageScore = (scoreAccumulate / gradedAssignments); //print average score cout << "The average score of these " << gradedAssignments << " assignments is " << averageScore; } // Section 8.4 // #2 //int main() //{ //defining variables //int baseLength = 0; //asking for input //cout << "Base length?" << endl; //cin >> baseLength; //cout << endl; //executing loops to create triangle //for (int b = baseLength; b <= baseLength, b != 0; b--) //{ //for (int a = b; a != 0; a--) //{ //cout << '*'; //} //cout << endl; //} //return 0; //} //Section 8.10 #3 //int main() //{ // int endValue = 0; int currentValue = 1; int behind_currentValue = 0; int currentBehindSum = 1; // cout << "Where would you like your Fibonacci sequence to terminate?\n"; // cin >> endValue; // cout << endl; // while (currentValue <= endValue) // { // cout << currentBehindSum << ' '; // currentBehindSum = currentValue + behind_currentValue; // behind_currentValue = currentValue; // currentValue = currentBehindSum; // } // cout << endl; // return 0; //} //6a //Section 8.2 # 1 //int main() //{ // //defining variables // int startValue = 0; //user prompt // cout << "Welcome to the descending even number program.\nPlease enter an integer between 1 and 50\n"; // cin >> startValue; // cout << endl; // //end program if startValue not 1-50 // if ((startValue < 50) && (startValue > 1)) // { // } // else // { // cout << "The number you have entered is not between 1 and 50. Try again." << endl; // return 0; // } // //check if startValue is odd, print once if odd skip if even // if ((startValue % 2) != 0) // { // cout << startValue; // cout << endl; // } // //calculations and display loop // for (startValue; (startValue >= 0); startValue--) // { // if ((startValue % 2) == 0) // { // cout << startValue << ' '; // } // else // { // } // } // cout << endl; // return 0; //} //Section 8.3 #1 //int main() //{ //defining variables //int startValue = 0; //user prompt and check if number is 1-50 //cout << "Welcome to the descending even number program.\nPlease enter an integer between 1 and 50\n"; //cin >> startValue; //cout << endl; //if ((startValue > 50) || (startValue < 1)) //{ // do // { // cout << "You have not entered an integer between 1 and 50. Please try again.\n"; // cin >> startValue; // cout << endl; // } while ((startValue > 50) || (startValue < 1)); //} //check if startValue is odd, print once if odd skip if even //if ((startValue % 2) != 0) //{ // cout << startValue; // cout << endl; //} //calculations and display loop //for (startValue; (startValue >= 0); startValue--) //{ // if ((startValue % 2) == 0) // { // cout << startValue << ' '; // } // else // { // } //} //cout << endl; //return 0; //}