Modify the while loop to utilize tolower() or toupper().  Add default values to the to_celsius() and to_fahrenheit() functions. Use the temperature when water freezes! CLARIFICATION: Only put the default value in the declaration of the function at the top of the program and NOT in the actual function below.  Example of code in the declaration section above main(): double to_celsius(double fahrenheit = 32.0);     Add two more functions to handle another type of conversion (distance, weight, etc.) and use function overloading. Overload the functions with double and int data types. Example (requiring four new functions): Kilograms to Pounds (using double) Pounds to Kilograms (using double) Kilograms to Pounds (using int) Pounds to Kilograms (using int) You could use miles to kilometers, etc. Add the factorial function that works by using recursion.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Topic Video
Question
#include <iostream>
#include <cmath>
 
using namespace std;
 
// declare functions
void display_menu();
void convert_temp();
double to_celsius(double fahrenheit);
double to_fahrenheit(double celsius);
 
int main() {
 
cout << "Convert Temperatures\n\n";
 
    display_menu();
    char again = 'y';
    while (again == 'y') 
    {
        convert_temp();
 
        cout << "Convert another temperature? (y/n): ";
        cin >> again;
        cout << endl;
    }
    cout << "Bye!\n";
}
 
// define functions
void display_menu() 
{
    cout << "MENU\n"
        << "1. Fahrenheit to Celsius\n"
        << "2. Celsius to Fahrenheit\n\n";
}
 
void convert_temp() 
{
    int option;
    cout << "Enter a menu option: ";
    cin >> option;
 
    double f = 0.0;
    double c = 0.0;
    switch (option) 
    {
        case 1:
            cout << "Enter degrees Fahrenheit: ";
            cin >> f;
 
            c = to_celsius(f);
            c = round(c * 10) / 10;        // round to one decimal place
 
            cout << "Degrees Celsius: " << c << endl;
            break;
        case 2:
            cout << "Enter degrees Celsius: ";
            cin >> c;
 
            f = to_fahrenheit(c);
            f = round(f * 10) / 10;       // round to one decimal place  
 
            cout << "Degrees Fahrenheit: " << f << endl;
            break;
        default:
            cout << "You must enter a valid menu number.\n";
            break;
    }
}
 
double to_celsius(double fahrenheit) 
{
    double celsius = (fahrenheit - 32.0) * 5.0 / 9.0;
    return celsius;
}
 
double to_fahrenheit(double celsius) 
{
    double fahrenheit = celsius * 9.0 / 5.0 + 32.0;
    return fahrenheit;
}
 
    • Modify the while loop to utilize tolower() or toupper(). 
    • Add default values to the to_celsius() and to_fahrenheit() functions.
      • Use the temperature when water freezes!

        • CLARIFICATION: Only put the default value in the declaration of the function at the top of the program and NOT in the actual function below. 
          • Example of code in the declaration section above main():

double to_celsius(double fahrenheit = 32.0);

  •  
  •  
    • Add two more functions to handle another type of conversion (distance, weight, etc.) and use function overloading.
      • Overload the functions with double and int data types.

      • Example (requiring four new functions):
        • Kilograms to Pounds (using double)
        • Pounds to Kilograms (using double)
        • Kilograms to Pounds (using int)
        • Pounds to Kilograms (using int)
      • You could use miles to kilometers, etc.
    • Add the factorial function that works by using recursion.
      • Example code given in class:
 

/*
    Recursion Example
        --Calculating a factorial
          Factorial of 5 = 1 * 2 * 3 * 4 * 5 = 120

          Need a function that "recursively" calls itself.
          Need a function that has a limiting point when recursion stops.
*/
#include <iostream>
using namespace std;

int factorial(int n);

int main()
{
    const int limit = 5;

    int fact = factorial(limit);
    cout << "Factorial of " << limit << " is: " << fact << endl;

    return 0;
}

int factorial(int n)
{
    if (n < 0) return(-1);      // negative number out of bounds, leave function
    if (n == 0) return(1);      // 0 means finished, leave function
    else
    {
        return (n * factorial(n - 1));   // recursive call 
    }
}

    • Write excellent comments:
      • At the top to show your name, the class, and what the program does.
      • For each function.
      • Critical or tricky parts that might be difficult to understand without a comment.
Expert Solution
steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Instruction Format
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-engineering and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY