# help with this code please!!!

Show 40 post(s) from this thread on one page
Page 1 of 2 12 Last
• March 31st, 2013, 10:31 AM
fon90
help with this code please!!!
Write a class that contains the following two methods:

/** Converts from Celsius to Fahrenheit */

Hello there guys please I need help with this program in java
this what i have done so far , please any help would much appreciated
Thanks.

< public class EX5_8{
public static void main(String args[]){
/* public static double celsiusToFahrenheit(double celsius){
return celsius=(5.0/9.0) * fahrenheit - 32;
}
public static double fahrenheitToCelsius(double fahrenheit){
return fahrenheit=(9.0/5.0) * fahrenheit + 32;
}*/
System.out.println("|Celsius |Fahrenheit||Celsius |Fahrenheit| \n");
int i=40;
int j=120;
do{
System.out.printf("%3.1f|%11.1f|%3.1f|%8.2f|\n",i, (i*(9.0/5)+32),j,(j/i*(5.0/9)-32));
i-=1;
j-=10;
}while(i<=31 && j<=30);
}
}
>

Find below is the complete question

public static double celsiusToFahrenheit(double celsius)

/** Converts from Fahrenheit to Celsius */
public static double fahrenheitToCelsius(double fahrenheit)

The formula for the conversion is:

fahrenheit = (9.0 / 5) * celsius + 32

Write a test program that invokes these methods to display the following tables:
Celsius Fahrenheit Fahrenheit Celsius
40.0 104.0 120.0 48.89
39.0 102.2 110.0 43.33
...
32.0 89.6 40.0 4.44
31.0 87.8 30.0 -1.11

Edit / Delete
• March 31st, 2013, 10:35 AM
Norm
Re: help with this code please!!!
Did you have any specific questions?

Please edit your post and wrap your code with code tags:
[code=java]
[/code]
to get highlighting and preserve formatting.
• March 31st, 2013, 10:50 AM
fon90
Re: help with this code please!!!
Yes please I just can get the program to print out the values it compiles
but is not working

This is the original question
Find below is the complete question

public static double celsiusToFahrenheit(double celsius)

/** Converts from Fahrenheit to Celsius */
public static double fahrenheitToCelsius(double fahrenheit)

The formula for the conversion is:

fahrenheit = (9.0 / 5) * celsius + 32

Write a test program that invokes these methods to display the following tables:
Celsius Fahrenheit Fahrenheit Celsius
40.0 104.0 120.0 48.89
39.0 102.2 110.0 43.33
...
32.0 89.6 40.0 4.44
31.0 87.8 30.0 -1.11
• March 31st, 2013, 10:56 AM
Norm
Re: help with this code please!!!
Quote:

but is not working
Can you describe what "not working" means?

Post your code and the program's output and add some comments saying what is wrong with the output.
• March 31st, 2013, 11:13 AM
fon90
Re: help with this code please!!!
I just want to be able to fit in the those methods in the program and make it work
now is saying [Exception in thread ] "main" illegalformatConversionException
• March 31st, 2013, 11:22 AM
Norm
Re: help with this code please!!!
Quote:

illegalformatConversionException
Please copy the full text of the error message and post it here.
• March 31st, 2013, 11:36 AM
fon90
Re: help with this code please!!!
Now is working without me uisng those methods < public static double celsiusToFahrenheit(double celsius){
return celsius=(5.0/9.0) * fahrenheit - 32;
}
public static double fahrenheitToCelsius(double fahrenheit){
return fahrenheit=(9.0/5.0) * fahrenheit + 32;
}>
and am getting a wrong value for celsius column 4
please .....I have tried to paste it here but it does not paste I don't know why sir..
• March 31st, 2013, 11:38 AM
Norm
Re: help with this code please!!!
Quote:

it does not paste
sorry, I don't know what your problem is. Most others are able to paste things here. How were you able to paste the code in post#1?
• March 31st, 2013, 11:44 AM
fon90
Re: help with this code please!!!
Find below is my exact out put right now ....

|Celsius |Fahrenheit||Celsius |Fahrenheit|

40.0| 104.0|120.0| 184.00|
Press any key to continue . . .
• March 31st, 2013, 11:45 AM
Norm
Re: help with this code please!!!
Do you have a question or comment about the output you posted?
• March 31st, 2013, 11:52 AM
fon90
Re: help with this code please!!!
yes, it is suppose to print out like this...
but I have not been able to make it work properly .

40.0 104.0 120.0 48.89
39.0 102.2 110.0 43.33
...
32.0 89.6 40.0 4.44
31.0 87.8 30.0 -1.11
• March 31st, 2013, 11:55 AM
Norm
Re: help with this code please!!!
Post the code in code tags and explain what is wrong with what the program prints out.
• March 31st, 2013, 12:05 PM
fon90
Re: help with this code please!!!
[import java.util.Scanner;

public class EX5_8{
public static void main(String args[]){
/* public static double celsiusToFahrenheit(double celsius){
return celsius=(5.0/9.0) * fahrenheit - 32;
}
public static double fahrenheitToCelsius(double fahrenheit){
return fahrenheit=(9.0/5.0) * fahrenheit + 32;
}*/
System.out.println("|Celsius |Fahrenheit||Celsius |Fahrenheit| \n");
double i=40;
double j=120;
do{
System.out.printf(" %3.1f|%11.1f | %3.1f | %8.2f |\n",i,(i*(9.0/5)+32),j,j/(5.0/9.0)-32);
i-=1;
j-=10;
}while(i<=31 && j<=30);
}
}][/QUOTE]
The program do not print the right out put, and I don't know how to use the methods posted above in the program please guidance...
• March 31st, 2013, 12:07 PM
Norm
Re: help with this code please!!!
Please edit your post and wrap your code with code tags:
[code=java]
[/code]
to get highlighting and preserve formatting.

Quote:

how to use the methods
Here's a tutorial on how to use methods:
http://docs.oracle.com/javase/tutori...arguments.html
http://docs.oracle.com/javase/tutori...turnvalue.html
• March 31st, 2013, 12:23 PM
fon90
Re: help with this code please!!!
Hey cono if you wanna help you do that ,
please al ready frustrated with this assignment and to be candid you are making things worst
you keep asking same questions all over the place..
i have showed you my code and where am @ .....
so please if you have ideas direct and and if can't no problem
my directed here thought I could get help
Thanks.
• March 31st, 2013, 12:33 PM
Norm
Re: help with this code please!!!
Your code is unformatted and hard to read. If you want help, you must format the code and wrap it in code tags.
I do not work with unformatted code that is hard to read.
When you format it, I will copy it and see what it does.
• March 31st, 2013, 12:43 PM
fon90
Re: help with this code please!!!
please how do I format and wrap the code ,and code tag it? this is my first time using this forum
• March 31st, 2013, 12:46 PM
Norm
Re: help with this code please!!!
Please edit your post and wrap your code with code tags:
[code=java] <<<< This goes before the code

[/code] <<<< This goes after the code
to get highlighting and preserve formatting.

The formatted code will look like this:
Code :

``` class TestGet<T> { public List<T> getList() { // warning: [rawtypes] found raw type: List return null; } }```
• March 31st, 2013, 12:55 PM
fon90
Re: help with this code please!!!
[code=java]
[/import java.util.Scanner;

public class EX5_8{
public static void main(String args[]){
/* public static double celsiusToFahrenheit(double celsius){
return celsius=(5.0/9.0) * fahrenheit - 32;
}
public static double fahrenheitToCelsius(double fahrenheit){
return fahrenheit=(9.0/5.0) * fahrenheit + 32;
}*/
System.out.println("|Celsius |Fahrenheit||Celsius |Fahrenheit| \n");
double i=40;
double j=120;
do{
System.out.printf(" %3.1f|%11.1f | %3.1f | %8.2f |\n",i,(i*(9.0/5)+32),j,j/(5.0/9.0)-32);
i-=1;
j-=10;
}while(i<=31 && j<=30);
}
}]
</The code is here also import java.util.Scanner;

public class EX5_8{
public static void main(String args[]){
/* public static double celsiusToFahrenheit(double celsius){
return celsius=(5.0/9.0) * fahrenheit - 32;
}
public static double fahrenheitToCelsius(double fahrenheit){
return fahrenheit=(9.0/5.0) * fahrenheit + 32;
}*/
System.out.println("|Celsius |Fahrenheit||Celsius |Fahrenheit| \n");
double i=40;
double j=120;
do{
System.out.printf(" %3.1f|%11.1f | %3.1f | %8.2f |\n",i,(i*(9.0/5)+32),j,j/(5.0/9.0)-32);
i-=1;
j-=10;
}while(i<=31 && j<=30);
}
}>

--- Update ---

Code java:

```<import java.util.Scanner;   public class EX5_8{ public static void main(String args[]){ /* public static double celsiusToFahrenheit(double celsius){ return celsius=(5.0/9.0) * fahrenheit - 32; } public static double fahrenheitToCelsius(double fahrenheit){ return fahrenheit=(9.0/5.0) * fahrenheit + 32; }*/ System.out.println("|Celsius |Fahrenheit||Celsius |Fahrenheit| \n"); double i=40; double j=120; do{ System.out.printf(" %3.1f|%11.1f | %3.1f | %8.2f |\n",i,(i*(9.0/5)+32),j,j/(5.0/9.0)-32); i-=1; j-=10; }while(i<=31 && j<=30); } }>```

--- Update ---

I formatted it well now
find above is the code
• March 31st, 2013, 01:00 PM
Norm
Re: help with this code please!!!
Code :

`}while(i<=31 && j<=30);`
This statement is false the first time the code is executed so the loop does not repeat.

Add this line just before the above while to see what the values of i and j are:
Code :

` System.out.println("i="+i + ", j="+j); // print out values of i & j`
• March 31st, 2013, 04:30 PM
fon90
Re: help with this code please!!!
ok, thanks but please how do include those methods in this program?
• March 31st, 2013, 04:32 PM
Norm
Re: help with this code please!!!
What methods? Please describe what they do and how they would be used in the program.
• March 31st, 2013, 04:50 PM
fon90
Re: help with this code please!!!
In the original question of this assignment we are asked to use
public static double celsiusToFahrenheit(double celsius){
return celsius=(5.0/9.0) * fahrenheit - 32;
}
public static double fahrenheitToCelsius(double fahrenheit){
return fahrenheit=(9.0/5.0) * fahrenheit + 32;
}

But if you look at my code i commented them because any I try to used them methods in my code I have tons of errors,please help me...
• March 31st, 2013, 05:05 PM
Norm
Re: help with this code please!!!
The names used in the methods are confusing: celsiusToFahrenheit() returns celsius. The name says it should return Fahrenheit.

Have you tested the two methods to see if their conversions are correct?
Call each with a value, print out what it returns and check that the conversion was done correctly.

Don't forget to use code tags when posting code.
• March 31st, 2013, 05:31 PM
fon90
Re: help with this code please!!!
am sorry thats just me ..
The question was include in your program
Code java:

```<public static double fahrenheitToCelsisu(double celsius) / /converts from CToF public static double celsiusToFahrenheit(double fahrenheit) / /converts fromFToC>```

--- Update ---

The want us to include those methods in the program
Show 40 post(s) from this thread on one page
Page 1 of 2 12 Last