// CST116F2021-Lab3.cpp : This file contains the 'main' function. Program execution begins and ends there. // #include #include using namespace std; int main() { //p.192 int input = 0, seq1 = 0, seq2 = 0, seq3 = 0; cout << "Please enter your ending number: "; cin >> input; cout << "1 1 "; if (seq1 == 0) seq1 = 1; seq2 += seq1; seq3 = seq1 + seq2; while (seq3 <= input) { cout << seq3 << ' '; seq1 = seq2; seq2 = seq3; seq3 = seq1 + seq2; } return 0; ////p.184 //int length = 0; //int height = 1; //cout << "Please input the base length of your triangle: "; //cin >> length; //height = length; //do { // do // { // cout << '*'; // length = length--; // } while (length != 0); // cout << "\n"; // height = height--; // length = height; //} while (height != 0); //return 0; //p.179 /*int input = 0; int remainder = 0; cout << "Please enter an integer between 1 and 50: "; cin >> input; do cout << "User input invalid. Please enter an integer between 1 and 50: "; while (input < 1 || input > 50); remainder = input % 2; if(remainder != 0) { input = input--; remainder = input % 2; } do { cout << input << ' '; input = input - 2; } while (input != 0); return 0;*/ //p.177 8.2 /* int input = 0; int remainder = 0; cout << "Please enter an integer between 1 and 50: "; cin >> input; if (input < 1 || input > 50) { cout << "User input invalid. Exiting program."; return -1; } remainder = input % 2; if(remainder !=0) { input = input--; remainder = input % 2; } while (input != 0) { cout << input << ' '; input = input - 2; } cout << "0."; return 0;*/ //p.168 //1. Take a loan within the correct bounds and calculate the interest and fees. //2. Program takes 2 inputs, loan and interest rate. Loan can only be between 100 and 1000 dollars and between 1 and 18% interest rate. Display an error otherwise and end the program. Determine loan fees based on the loan amount. Calculate the interest and display loan, interest rate, and sum of the interest and fees. //3.? //4. /*1. Define loan, interest rate, interest value, fees, and sum * 2. Accept user inputs for loan and interest rate values 3. Compare loan and interest rate to set range If not within range, output an error and end. 4. Compare loan to a range that determines the fees 5. Calculate the interest on the loan. 6. Print Loan, Interest Rate, and the sum of the interest and fees.*/ /*float loan = 0; float rate = 0; float interest = 0; int fees = 0; float sum = 0; cout << "Please input the loan amount from 100 to 1,000 dollars: "; cin >> loan; if (loan >= 100 && loan <= 1000) cout << "Please input the percent interest rate: "; else { cout << "\nInvalid response. Ending program.\n"; return 1; } cin >> rate; if (rate >= 1 && rate <= 18) cout << "\nYour loan is for $" << loan << " at " << rate << "% interest."; else { cout << "\nInvalid response. Ending program.\n"; return 2; } if (loan >= 100 && loan <= 500) { cout << "\nThere is a fee of $20 for a loan of this value.\n"; fees = 20; } else { cout << "\nThere is a fee of $25 for a loan of this value.\n"; fees = 25; } interest = loan * (rate/100); sum = interest + fees; cout << "\nYou have chosen a loan of $" << loan << " at an interest rate of " << rate << "%.\n"; cout << "Your interest and fees come to a total of $" << sum << ".\n"; return 0;*/ //p.161 /* int menu = 0; cout << setw(38) << "Student Grade Program\n" << setw(35) << "- Main Menu -\n\n" << setw(27) << "1. Enter Name\n" << setw(34) << "2. Enter test scores\n" << setw(36) << "3. Display test scores\n" << setw(22) << "9. Exit\n\n" << setw(52) << "Please enter your choice from the list above: "; cin >> menu; switch (menu) { case 1: cout << "\tYou have selected \"Enter name\"\n"; break; case 2: cout << "\tYou have selected \"Enter test scores\"\n"; break; case 3: cout << "\tYou have selected \"Display test scores\"\n"; break; case 9: cout << "\tYou have chosen to exit the program.\n"; break; default: cout << "\tInvalid selection.\n"; } return 0;*/ //p.155 //int account = 0; //float balance = 0; //while (account != 1 && account != 2 && account != 3) //{ // cout << "Enter 1 for Checking, 2 for Savings, or 3 for both: "; // cin >> account; // if (account == 1) // cout << "You have a Checking account."; // else if (account == 2) // cout << "You have a Savings account."; // else if (account == 3) // cout << "You have both a Checking and Savings account."; // else // cout << "Error. Please enter a valid account type."; //} //cout << "\nPlease enter account balance: "; //cin >> balance; //if (balance >= 25000 && account == 3) // cout << "You have a Platinum membership for Checking and Savings."; //else if (balance < 25000 && balance >= 10000 && account == 3) // cout << "You have a Gold membership for Checking and Savings."; //else if (balance > 10000 && account != 3) // if (account == 1) // cout << "You have a Silver membership on a Checking account."; // else // cout << "You have a Silver membership on a Savings account."; //else // if (account == 1) // cout << "You have a Copper membership on a Checking account."; // else // cout << "You have a Copper membership on a Savings account."; // //cout << "\n"; //return 0; }