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

  • Home
  • SEARCH
  • 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 9226831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:55:26+00:00 2026-06-18T04:55:26+00:00

I have a Fahrenheit class thats supposed to take a number from the main

  • 0

I have a Fahrenheit class thats supposed to take a number from the main class and convert it into celsius.
Everything works but the conversion part.
I made a method that I call so that the number can be converted, but whenever the program runs it gives me either -0.0 or 0.0 (no matter what the number is) I know that the negative part is correct but i just need it to show the actual converted number.

It has been an entire year since I’ve done any sort of java programming and I’m still a beginner.I’ve looked up the java docs to get a refresher and wrote simple simple programs to get back in the game but im lost with this one. please any input would be helpful

heres the main class

public class test { 
  public static void main (String[] args) {
    double t = 100;

    Fahrenheit temp = new Fahrenheit(t);

    temp.convert();

  }
}

and the fahrenheit class

public class Fahrenheit{

 private double tempF = 0;

 public Fahrenheit (double inputTemp){
    tempF = inputTemp;
 }

public double convert () {

    double c = 5/9*(tempF-32);

    System.out.println(c );
    return c;
 }
}
  • 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-06-18T04:55:27+00:00Added an answer on June 18, 2026 at 4:55 am
    double c = 5/9*(tempF-32);
    

    In the above line, you are performing integer division – 5 / 9, whose result is 0. Hence you got 0.0.

    You can either change one of the numerator or denominator to a double value: –

    double c = 5.0 / 9 * (tempF-32);
    

    or, just do the multiplication first: –

    double c = 5 * (tempF-32) / 9 ;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I can convert from fahrenheit to celcius, but not the other way around. I
I have a fun program that displays temperatures. Everything works fine, until I try
I had to write 3 functions: one to convert Fahrenheit to Celsius, one to
I have quite straight forward question. The following code prints out celsius and fahrenheit.
have written this little class, which generates a UUID every time an object of
have a nice day. I got problem when trying to create an image from
I am writing a simple console application in Objective-C but I have heard that
OK, so I have my main.m program code, and mvds suggested I free the
I have an app which has a section that needs to convert the temperature
I have custom buttons that are supposed to have different backgrounds depending if they

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.