Write a program that converts temperature from degrees Fahrenheit to degrees Celsius .The formula is C = (5.0/9.0) (F-32)

Schol-R-LEA commented: Do your own homework. -3
rproffitt commented: Really? -4

Recommended Answers

All 5 Replies

First off, we don't do other people's homework for them. Second, we don't do other people's homework for them. And third, we don't do other people's homework for them. Sensing a pattern here yet?

No one here will simply hand you a solution on a silver platter. If you show us what you've done, what you've tried to do, and what problems you've had with it, then we'll be happy to help. If you have specific questions, we can answer them, or at least point you in the right direction. If you have a program with a bug you can't swat on your own, we'll be glad to assist, so long as you pay attention to the forum rules and post sensible questions in an intelligent manner that we have some reasonable hope of answering.

But just cutting and pasting an assignment into a message, without even prefacing it with something like, "I have this homework problem that I can't solve...", is likely to get you booted from the message boards here and elsewhere - if you're lucky. What happens to you if you are unlucky is... well... let's just say that this guy probably won't be trying that again, on that forum or this one.

We take this issue seriously here. Very seriously. Asking us to do homework for you is a grave breach of academic ethics on your part, and actually doing so would be an even bigger breach on ours (not that this stops the many fine mercenaries at Freelancer.com, but still). Simply posting this here, in this way, could get you expelled from your school, if someone happens to notice it and blow the whistle on you. Furthermore, it does neither you nor us any good to help you cheat - especially since there's a good chance some day one of us will have to work with you, manage you, or, Eris forefend, fix code you've written. We have an obligation to our profession and our own future sanity to help you become a good programmer, and doing your coursework for you isn't going to do that.

And if you think you won't get caught by your professor... think again. Most professors will do simple searches on code samples they receive in order to catch cheaters (or more likely, have their TAs and grad students do it for them).

And please don't insult our intelligence by claiming that it isn't a class assignment. It's very easy to spot one, and we have a lot of practice at it. Trust me on this.

Now, if you actually don't know how to create a program that fits the requirements... hmmmn. Reading the book is definitely called for. As is speaking to the professor; while some can be a--holes about office hours, most are more than willing to give extra help, if only to keep their class grades from slipping to the point where they get re-assigned to teach remedial basketweaving.

Please let us know the email address for your teacher so we can submit the code directly to him/her and save you all that tedious copy/pasting. I'm sure you'll get an A+ for finding such a cunning way to handle the assignment.

Here is a simple conversion from F to C.

#include <iostream>

int main()
{
    float f_temp = 0.0;
    float c = 0.0;
    while (1) {
    std::cout << " Enter Fahrenheit Temperature: ";
        std::cin >> f_temp;
        c = (static_cast<float>(5) / 9) * (f_temp - 32);
        std::cout << " Temperature in Celsius: " << c << std::endl;
    }
    return 0;
}

Enter Fahrenheit Temperature: 32
Temperature in Celsius: 0
Enter Fahrenheit Temperature: 212
Temperature in Celsius: 100
Enter Fahrenheit Temperature: -40
Temperature in Celsius: -40
Enter Fahrenheit Temperature: 100
Temperature in Celsius: 37.7778
Enter Fahrenheit Temperature:

Notice the differences from C++ to Java:

import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner myObj = new Scanner(System.in);
while(true){
    System.out.println("Enter Fahrenheit Temperature: ");
    float fahrenheit = myObj.nextFloat();
    float c = (float)5/9;
    float ftoc = fahrenheit - 32;
    float celsius = c * ftoc;
    System.out.println("Fahrenheit: " + fahrenheit);
    System.out.println("Celsius: " + celsius);
    }
  }
}

Enter Fahrenheit Temperature:

32
Fahrenheit: 32.0
Celsius: 0.0
Enter Fahrenheit Temperature:
212
Fahrenheit: 212.0
Celsius: 100.00001
Enter Fahrenheit Temperature:
-40
Fahrenheit: -40.0
Celsius: -40.0
Enter Fahrenheit Temperature:
100
Fahrenheit: 100.0
Celsius: 37.77778
Enter Fahrenheit Temperature:

Notice the differences between C++ and Java:

import java.util.Scanner;

class Main {
  public static void Main(String[] args) {
    Scanner myObj = new Scanner(System.in);
while(true){
    System.out.println("Enter Fahrenheit Temperature: ");
    float fahrenheit = myObj.nextFloat();
    float c = (float)5/9;
    float ftoc = fahrenheit - 32;
    float celsius = c * ftoc;
    System.out.println("Fahrenheit: " + fahrenheit);
    System.out.println("Celsius: " + celsius);
    }
  }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.