Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6950521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:06:10+00:00 2026-05-27T14:06:10+00:00

In this program Iam trying to take 78 degrees Fahrenheit and return them in

  • 0

In this program Iam trying to take 78 degrees Fahrenheit and return them in a class with the Celsius version and kelvin. But for some odd reason I’m just getting this as the output. What am I doing wrong?

This is my output.

78
0
273.15
#include <iostream>
using namespace std;


class Temperature
{
public:

    double getTempKelvin();
    double getTempFahrenheit();
    double getTempCelcius();

    void setTempKelvin(double k);
    void setTempFahrenheit(double f);
    void setTempCelcius(double c);

private:
    double kelvin, fahrenheit, celcius;
    double c, f, k;
};

int main ()
{
    double c, f, k;
    Temperature Conv;

    Conv.setTempFahrenheit(f);
    Conv.setTempCelcius(c);
    Conv.setTempKelvin(k);
    cout << Conv.getTempFahrenheit() << endl;
    cout << Conv.getTempCelcius() << endl;
    cout << Conv.getTempKelvin() << endl;



    return 0;
}

void Temperature::setTempFahrenheit(double f)
{
    f = 78;
    fahrenheit = f;
}

void Temperature::setTempCelcius(double c)
{
    c = (5/9) * ( f - 32);
    celcius = c;
}

void Temperature::setTempKelvin(double k)
{
    k = c + 273.15;
    kelvin = k;
}




double Temperature::getTempFahrenheit()
{
    return fahrenheit;
}

double Temperature::getTempCelcius()
{
    return celcius;
}


double Temperature::getTempKelvin()
{
    return kelvin;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T14:06:11+00:00Added an answer on May 27, 2026 at 2:06 pm

    5/9 is integer division and will result in 0. You need to use doubles, Try:

    void Temperature::setTempCelcius(double c)
    {
        c = (5.0/9.0) * ( f - 32);
        celcius = c;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi iam new to c++ and iam trying out this vector program and i
I'm probably going to take some heat for this question. But I'd like to
I am trying to compile a one-off script, an autogenerated C# program. This program
I have a program that I am trying to take a set of numbers
I am trying to program a email piping php script that would take an
I am trying to create a java program that will take in a directory
I am trying to improve my C++ by creating a program that will take
This is the general goal I am trying to achieve: My VB.NET program will
I am trying to write a fragment program that will take a texture and
I'm really new to this. I am trying to write a CGI program that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.