Member Avatar

I honestly have no clue how to go about this. Need some assistance on the following questions:

  1. Modify the program to subtract (num1 – num2). If num2 is greater than num1, swap the values of the variables using a variable named temp, using the partial code below.

    if (num2 > num1)
        temp = num2;
  2. Problem Specification:
    Code the IPO Charts shown below for main function, getFahrenheit function, and calcCelsius function. Enter your C++ instructions into a source file named yourLastName_U5W1_EX1.cpp. Enter any appropriate comments in your code. Display the Celsius temperature in fixed-point notation with no decimal places. Save and then run the program. Test the program using the following, Fahrenheit temperatures: 32 and 212.

Main Function
IPO Chart Information

Fahrenheit temperature double fahrenheit = 0.0;
Celsius temperature double celsius = 0.0;
1. call getFahrenheit to get the Fahrenheit temperature
2. call calcCelsius to calculate the Celsius temperature, pass the Fahrenheit temperature
3. display the Celsius temperature (in fixed-point notation with no decimal places)
getFahrenheit Function
IPO Chart Information
Fahrenheit temperature double fahrenheitTemp = 0.0;
Return Output:
Fahrenheit temperature
1. Enter the Fahrenheit temperature cout << “Enter temperature in Fahrenheit”;
2. Return the Fahrenheit temperature
calcCelsius Function
IPO Chart Information
Fahrenheit temperature as formal parameter double fahrenheitTemp
Return Output:
Celsius temperature double celsiusTemp = 0.0;
1. Celsius temperature = 5.0 / 9.0 * (Fahrenheit temperature – 32.0)
2. Return the Celsius temperature

Recommended Answers

All 2 Replies

That question 2 looks like it's straight out of a book on programming C++. In fact the one I looked up had it on page 321. To me a quick flip through the book seems to show there's a lot of text and work you had to complete before this exercise was given out. Maybe you need to go back to the chapters before this exercise?

commented: True. I totally forgort. Here's all the work I've done. Please help debug. +0
Member Avatar

#include <iostream>
#include <iomanip>
using namespace std;

double getFahrenheit();
double calcCelsius(double fahrenheitTemp);

int main()
    double fahrenheit = 0.0;
    double celsius = 0.0;

    fahrenheit = getFahrenheit();
    celsius = calcCelsius(fahrenheit); 

    //display output
    cout << fixed << setprecision(0);
    cout << "Celsius: " << celsius << endl;

    return 0;
} //end of main function

double getFahrenheit()
    double fahrenheitTemp = 0.0;
    cout << "Enter Fahrenheit temperature: ";
    cin >> fahrenheitTemp;
    return fahrenheitTemp;
}//end of getFahrenheit

double calcCelsius(double fahrenheitTemp)
    double celsiusTemp = 0.0;
    celsiusTemp = 5.0 / 9.0 * (fahrenheitTemp - 32.0);
    return celsiusTemp;
} //end of calcCelsius
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.