//====================================================== //= CODE FOR PROBLEM #1 ON PAGE 161 IS BELOW = //====================================================== // //#include // //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 // //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 // //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 // //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 // //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 // //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; //}