# Thread: help w/ conversion of degrees(CtoF, FtoC)

1. Member
Join Date
Oct 2010
Posts
44
Rep Power
0

## help w/ conversion of degrees(CtoF, FtoC)

here is what we're supposed to do
This assignment is a Celsius to Fahrenheit and Fahrenheit to Celsius temperature conversion program.

Write a class that contains the following two methods ( class will have a total of 3 methods ):
public static double celtofahr ( double celsius)
and public static double fahrtocel ( double fahrenheit )

main should prompt the user for a celsius, call / use the celtofahr method to do the conversion, next display the result to the user. Next, prompt the user for a Fahrenheit, call / use the fahrtocel method to do the conversion, next display the result to the user.

Note : the formula for conversion is
fahrenheit = ( ( 9.0 / 5.0 ) * celsius ) + 32

WHERE DO I PUT THE STRING TO PROMPT THE USER TO ENTER EACH DEGREE?

here is my code

public class Assign8_Roberts{

private double fahrenheit;
private double celsius;
private String displayString;

public Assign8_Roberts (double Fahrenheit, double Celsius)
{
this.fahrenheit = Fahrenheit;
this.celsius = Celsius;
}

public double GetFahrenheitTemp()
{
return this.fahrenheit;
}

public double FahrtoCel(double fahrenheit)
{
double result = (fahrenheit - 32)/1.8;
return result;
}

public double GetCelsiusTemp()
{
return this.celsius;
}

public void FahrenheitTemp(double fahrenheitVal)
{
this.fahrenheit = fahrenheitVal;
}

public double CeltoFahr(double celsius)
{
double result = (1.8 * celsius) + 32;
return result;
}

public void CelsiusTemp(double celsiusVal)
{
this.celsius = celsiusVal;
}

}

2. Originally Posted by clemsontigers
here is what we're supposed to do...

main should prompt the user for a celsius, call / use the celtofahr method to do the conversion, next display the result to the user. Next, prompt the user for a Fahrenheit, call / use the fahrtocel method to do the conversion, next display the result to the user.

....

WHERE DO I PUT THE STRING TO PROMPT THE USER TO ENTER EACH DEGREE?
The instructions tell you where -- see the red above. You're missing a method.

3. Member
Join Date
Oct 2010
Posts
44
Rep Power
0
To DB(aka java forum police):does it really matter if i posted it on another board..isnt that what these are for?? imma post this same reply on the other board to p!\$\$ u off

to the other guys who help:thanks

here's my updated program..when i run it, it runs previous assignment that i've done instead of this one so something isnt right

import java.util.Scanner ;

public class Assign8_Roberts{

private double fahrenheit;
private double celsius;
private String displayString;

public Assign8_Roberts (double Fahrenheit, double Celsius)
{
this.fahrenheit = Fahrenheit;
this.celsius = Celsius;
}

public double GetFahrenheitTemp()
{
return this.fahrenheit;
}

public double FahrtoCel(double fahrenheit)
{
double result = (fahrenheit - 32)/1.8;
return result;
}

public double GetCelsiusTemp()
{
return this.celsius;
}

public void CelsiusTemp(double celsiusVal)
{
this.celsius = celsiusVal;
{
Scanner scan = new Scanner(System.in);
System.out.println("Enter a value: ");

float c = scan.nextFloat();

//use c as input to your methods
}
}
public void FahrenheitTemp(double fahrenheitVal)
{
this.fahrenheit = fahrenheitVal;

{
Scanner scan = new Scanner(System.in);
System.out.println("Enter a value: ");

float f = scan.nextFloat();

//use f as input to your methods
}

}

public double CeltoFahr(double celsius)
{
double result = (1.8 * celsius) + 32;
return result;
}

}

4. Senior Member
Join Date
May 2010
Posts
436
Rep Power
11
Originally Posted by clemsontigers
To DB(aka java forum police):does it really matter if i posted it on another board..isnt that what these are for?? imma post this same reply on the other board to p!\$\$ u off
No one wants to waste time working out someone's problem when it's already been solved elsewhere in a cross-post. Ignoring this implies that the poster doesn't respect the time commitment made by the volunteers of the various forums. The best thing to do is to notify all if you've made cross-posts and where you've made them. This forum is no different from any of the others in this regard.

Saying "pi\$\$-off" may feel good at the time, but isn't likely to encourage others to help you further.

Suerte.

5. Member
Join Date
Oct 2010
Posts
44
Rep Power
0
ok i've changed my program around and while im getting the correct results, im not sure if i have it designed the way the assignment says

public class Assign8_Roberts{

public static void main(String[] args)
{

double fahrenheit;
double celsius;

Scanner input = new Scanner(System.in);

System.out.println("Enter the Degrees in Fahrenheit");
fahrenheit = input.nextDouble();
celsius = (5.0/9.0)*(fahrenheit - 32);
System.out.println("The number of degrees of Fahrenheit: " + fahrenheit);
System.out.println("Converted to Celsius is: " + celsius);//end convert to celsius

System.out.println("Enter the Degrees in Celsius");
celsius = input.nextDouble();
fahrenheit = (9.0/5.0)* celsius + 32;
System.out.println("The number of degrees of Celsius: " + celsius);
System.out.println("Converted to Fahrenheit is: " + fahrenheit);
}

}

6. Agree that the cross-posting issue is important. OP, you might want to address this, let us know if there are any more cross-posts and let us know that you will notify us and all other forums for cross-posts in the future. Thank you for your cooperation.

7. Member
Join Date
Oct 2010
Posts
44
Rep Power
0
im getting errors in the output now

import java.util.Scanner;

public class Assign8_Roberts{

//Converts between CandF
private double celsius;
private double fahrenheit;

//converts from CtoF
public void CeltoFahr(double temp){
fahrenheit = (9.0/5.0*temp) + 32;
celsius = temp;
}

//converts from FtoC
public void FahrtoCel(double temp){
celsius = (5.0/9.0) * (temp-32);
fahrenheit = temp;
}

//displays temp in C
public void outputCelsius(){
System.out.println("The temperature is " + celsius + "C");
}

//displays temp in F
public void outputFahrenheit(){
System.out.println("The temperature is " + fahrenheit + "F");
}

//output
public static void main(String[] args) {
Scanner temp = new Scanner(system.in);
temp t = new temp();
t.setCelsius(100);
t.outputFahrenheit();
t.outputCelsius();
}

}

8. Senior Member
Join Date
Feb 2010
Location
Ljubljana, Slovenia
Posts
470
Rep Power
11
Snapping at a respected member of this forum because he informed you of a forum etiquette faux pas is not a good way to get help. Why crossposting is looked down upon has been explained already.

9. Member
Join Date
Oct 2010
Posts
44
Rep Power
0
Im new to the board and didn't know about the crossposting policy and thats why I apologized

10. Moderator
Join Date
Feb 2009
Location
New Zealand
Posts
4,716
Rep Power
18
To DB(aka java forum police):does it really matter if i posted it on another board[?]

A couple of things. First, it matters to me. I know you didn't address the question at me, but I'll answer anyway because that's how forums and dialogue in general works: you say/ask/observe something and people say/ask/observe things in response. And it matters to me mostly because crossposting frustrates that process of dialogue. Anyone participating in a discussion either doesn't know about - or has to jump through hoops to see - the rest of the dialogue. When you create a thread you offer it to the community. Those who respond, by responding make it their own. The thread is common property.

Secondly, "police"? That is simply not how it works. It's rhetoric, not fact. There are no police. What there are people engaged in dialogue (see above) who, by their participation, establish and sustain norms of conduct. No police: just people being civil.
Last edited by pbrockway2; 11-08-2010 at 10:02 PM.

11. Member
Join Date
Oct 2010
Posts
44
Rep Power
0
I apologize for my previous postt

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•