-2

I'm trying to write a program that takes a value in the Fahrenheit scale, validates the value to ensure that it is legitimate, and returns the proper value for Fahrenheit, Celsius, and Newton.

The code below keeps giving error messages for Lines 21, 25, 29 (The void's)

#include <iostream>
using namespace std;

class temperature {
public:

double getFahrenheit();
double getCelsius();
double getNewton();

void setFahrenheit();
void setCelsius();
void setNewton();

private:
    double fahrenheit, Celsius;
    double c, f;

};
void freezing.setFahrenheit(){
    f = 32;
    fahrenheit = f;
}
void freezing.setCelsius(){
    c = (5.0/9.0) * ( f - 32);
    celsius = c;
}
void freezing.setNewton(){
n=(33.0/100.0)*c;
newton=n;

double freezing.getFahrenheit(){
    return fahrenheit;
}

double freezing.getCelsius(){
    return Celsius;
}
Double freezing.getNewton(){
Return Newton;
}
int main() {



Temperature freezing(32);
Freezing.setFahrenheit();                                                                         Freezing.setCelsius();
Freezing.setNewton();

cout << "water freezes at " << freezing.getFahrenheit() << " Fahrenheit, " << freezing.getCelsius() << " Celisus, and " << freezing.getNewton() << " Newton" << endl;




return 0;

}

  • 3
    You might want to check out [The Definitive C++ Book Guide and List](http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list), because you really need to get some basic understanding of the language. – Some programmer dude May 05 '14 at 13:08

1 Answers1

0

You need to use :: instead of . Moreover, your class is called temperature and not freezing

void temperature::setFahrenheit()

See also this question

There's a few other errors too:

void temperature::setCelsius(){ //and not void freezing.setCelsius
    c = (5.0/9.0) * ( f - 32);
    celsius = c;
}

Here you reference celsius , but the temperature class defines Celsius with a captial C.

void freezing.setNewton(){
n=(33.0/100.0)*c;
newton=n;

Here you use the n and newton variables, but you have not defined them anywhere. They should perhaps be members of your temperature class.

Double freezing.getNewton(){
    Return Newton;
}

Here you have capital letters, which doesn't make sense, it should be

double temperature::getNewton(){
     return newton; //you need to make this a member variable of your class too..
}

Temperature freezing(32);

Your temperature class has a lowercase t , the Temperature class doesn't exist. And there's no constructor defined, so you can't pass 32 in there.

Freezing.setFahrenheit();
Freezing.setCelsius();

These 2 lines references Freezing, but you called your variable freezing

Community
  • 1
  • 1
nos
  • 223,662
  • 58
  • 417
  • 506
  • @user3238772 You also have a lot of errors with using capital letters, e.g. Double vs double, Freezing vs freezing and so on. – nos May 05 '14 at 13:04
  • @user3238772 You don't have a class named `freezing`, it's called `temperature`. – Some programmer dude May 05 '14 at 13:07
  • @nos thanks, I've cleared up those problems. Now I'm getting the following error message after each double temperature. "a function-definition is not allowed here before ‘{’ token" – user3238772 May 05 '14 at 13:34