#include #include using namespace std; ////////////////////////////////////////////////////// // Rules: You may NOT edit the main program! // Instead, you need to write the functions so // that they work as described in the comments // with the current main program, unchanged. ////////////////////////////////////////////////////// int main() { //Implement min and max functions. cout << maxValue(10, 2.2, 7) << endl; // 10 cout << maxValue(4.9, 5, 5) << endl; //5 cout << maxValue(8, 10, 20.3) << endl; //20.3 cout << minValue(6, 20, 3) << endl; //3 cout << minValue(3.14, 1.17, 8.3) << endl; //1.17 //Implement isEven, isOdd, isPrime boolean functions int n; cout << "Enter a number: " << endl; cin >> n; if (isEven(n)) { cout << n << " is even." << endl; } if (isOdd(n)) { cout << n << " is odd." << endl; } if (isPrime(n)) { cout << n << " is prime." << endl; } //Add, multiply functions cout << add(5, 2) << endl; // 7 cout << add(-4.2, 23) << endl; // 18.8 cout << multiply(5, 3) << endl; // 15 cout << multiply(7, 10) << endl; // 70 //Create a function that sums the numbers between the given range int total1 = sum(8, 20); //this should be 8+9+10+...+20 = int total2 = sum(9, 35); cout << "The sum from 8 to 20 is " << total1 << endl; cout << "The sum from 9 to 35 is " << total2 << endl; //Great, now let's get serious: write a function that //will list all the prime numbers from 1 up to a given number n. //Hint: Functions may call other functions, even other functions that *you* have written. listPrimes(10); //Should print: 2,3,5,7 listPrimes(20); //Should print: 2,3,5,7,11,13,17,19 //A better way to do your homework assignment: //Use the phone pacage information from homework 2 //to write a function that computes the amount of money owed //based on a given phone plan and the usuage hours for the month. double moneyOwed1 = computeBill("basic", 237); double moneyOwed2 = computeBill("gold", 23); cout << "first bill: " << moneyOwed1 << " second bill: " << moneyOwed2 << endl; //463.95 and 17.95 ////////////////////////////////////////////////////////////////////////////// //Before crossing into the test code below: Make sure you have read //about passing by reference. ////////////////////////////////////////////////////////////////////////////// //capital, and makeCaptial char letter = 'f'; char bigLetter = capital(letter); cout << letter << endl; // f cout << bigLetter << endl; // F char letter2 = 'd'; makeCaptial(letter2); cout << letter2 << endl; // D //swap! int x = 5; int y = 10; swapValues(x, y); cout << x << ", " << y << endl; // 10, 5 int w = 33; int z = 20; swapValues(w, z); cout << w << ", " << z << endl; // 20, 33 return 0; }