bananaamy
asked on
Looping ????
I have used looping in C++ before, HOWEVER, I am learning to use public and private classes. If I write my program without class I have no problem using a "do/while" or "if /else" statements. Is the looping funtion different when using public and private class? I am going to post the code that I am working with below. My request is that you don't fix my code, but add a comment(s) that helps me to learn. If I dont get It I will repost with a more specific question. Thank you much!!!
#include <iostream>
using namespace std;
class temp
{
private:
static float num1;
static float num2;
double numF;
double numC;
public:
void inputTempF();
void calcTemp();
void displayTempC();
};
float temp::num1 = .555555;
float temp::num2 = 32;
main()
{
temp theTemp;
do
{
theTemp.inputTempF();
theTemp.calcTemp();
theTemp.displayTempC();
}
while
(theTemp.inputTempF()!= 9999);
system("Pause");
}
void temp::inputTempF()
{
cout << "Please enter a temp in F: ";
cin >> numF;
cout << endl;
}
void temp::calcTemp()
{
numC =(num1*(numF-num2));
}
void temp::displayTempC()
{
cout << "The C temp is "<< numC ;
cout << endl;
}
#include <iostream>
using namespace std;
class temp
{
private:
static float num1;
static float num2;
double numF;
double numC;
public:
void inputTempF();
void calcTemp();
void displayTempC();
};
float temp::num1 = .555555;
float temp::num2 = 32;
main()
{
temp theTemp;
do
{
theTemp.inputTempF();
theTemp.calcTemp();
theTemp.displayTempC();
}
while
(theTemp.inputTempF()!= 9999);
system("Pause");
}
void temp::inputTempF()
{
cout << "Please enter a temp in F: ";
cin >> numF;
cout << endl;
}
void temp::calcTemp()
{
numC =(num1*(numF-num2));
}
void temp::displayTempC()
{
cout << "The C temp is "<< numC ;
cout << endl;
}
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER