write a program with a class that creates a class that will inherit the Fahrenhe
ID: 3539851 • Letter: W
Question
write a program with a class that
creates a class that will inherit the Fahrenheit class. The program should allow a user to input a Celsius temperature and
a floating-point humidity (ex: .80). Using the class and the inherited class, calculate the Fahrenheit temperature and
based on the percentage of humidity, add or subtract the appropriate degree.
Output the Fahrenheit degree and the weather status as follows:
Today%u2019s temperature is 80 degrees Fahrenheit.
Today is a hot day.
If humidity is:
80 %u2013 100 percent add 5 degrees to Fahrenheit temperature,
60 %u2013 79 percent add 3 degrees to Fahrenheit temperature,
40 %u2013 59 percent add 1 degree to Fahrenheit temperature,
Below 40 subtract 1 from Fahrenheit temperature.
Explanation / Answer
#include <iostream>
using namespace std;
class abc
{
public:
void Fahr(double C)
{
double F;
F=(9/5)*C+32;
cout<<F;
}
};
class Fahrenheit : public abc
{
public:
void fah(double bb)
{
abc :: Fahr(bb);
}
};
int main()
{
double aa;
cout<<"please enter Celsius";
cin>>aa;
Fahrenheit f1;
f1.fah(aa);
cin>>aa;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.