Programming
--
Questions
--
Followers
Top Experts
Celsius=(5/9)*(fahrenheit-
Your program reads a Fahrenheit degree in double from the keyboard then converts it to Celsius and display the result.
Zero AI Policy
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
Homework won't be done here. After reading the Java Tutorial at http://java.sun.com/docs/books/tutorial/index.html you should be able to do this problem yourself.
Thanks for the whip whip.
In the meantime, take a look at the Java Tutorial -- it's very good and will certainly get you going with java.






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
I know how to set the environment, compile using javac to produce class file, run the java program already.
How about a deal? I give you the codes in C programming and you help me out in this. (to make me feel less guilty).
Emms
#include<math.h>
main()
{
float fahrenheit, celsius;
clrscr();
printf("Enter Fahrenheit to convert to Celsius: ");
scanf("%f", &fahrenheit);
celsius = (5/9)*(fahrenheit-32);
printf("%f Fahrenheit = %f Celsius", fahrenheit, celsius);
}
Question revised: Convert this c codings to java codings.
here are some FREE hints for you:
-
How to write a skeleton of Java application:
public class MyApplication
{
public static void main( String[] args )
{
// your code goes here
}
}
-
How to declare variables of types "int" and "double" (integer and floating-point numbers) ?
int radius;
int height;
double volume;
-
How to print something to the system output:
System.out.println( "Something" );
System.out.println( "Radius of the base is "+radius );
-
How to read an integer value from the system input (SHORT VERSION, terminate application on invalid input):
int inputAsIntegerValue;
System.out.print( "Please enter an integer value: " );
try
{
inputAsIntegerValue = Integer.parseInt( System.in.readln() );
}
catch( NomberFormatException e )
{
System.out.println( "Input "+inputAsString+" is not a valid int value!" );
System.exit( 0 );
}
System.out.println( "The value is "+inputAsIntegerValue );
-
How to read an integer value from the system input (LONG VERSION, loop until you get a valid number):
String inputAsString = null;
int inputAsIntegerValue;
System.out.print( "Please enter an integer value: " );
while (inputAsString == null)
{
try
{
inputAsString = System.in.readln();
inputAsIntegerValue = Integer.parseInt( inputAsString );
}
catch( NomberFormatException e )
{
System.out.println( "Input "+inputAsString+" is not a valid int value! Again, please." );
inputAsString = null;
}
}
System.out.println( "The value is "+inputAsIntegerValue );
-
How to read a floating-point number (of the type "double") from the system input (SHORT VERSION):
int inputAsDoubleValue;
System.out.print( "Please enter a double value: " );
try
{
inputAsDoubleValue = Double.parseDouble( System.in.readln() );
}
catch( NomberFormatException e )
{
System.out.println( "Input "+inputAsString+" is not a valid double value!" );
System.exit( 0 );
}
System.out.println( "The value is "+inputAsDoubleValue );
-
How to read a floating-point number (of the type "double") from the system input (LONG VERSION):
String inputAsString = null;
double inputAsDoubleValue;
System.out.print( "Please enter a double value: " );
while (inputAsString == null)
{
try
{
inputAsString = System.in.readln();
inputAsDoubleValue = Double.parseDouble( inputAsString );
}
catch( NomberFormatException e )
{
System.out.println( "Input "+inputAsString+" is not a valid double value! Again, please." );
inputAsString = null;
}
}
System.out.println( "The value is "+inputAsDoubleValue );
-
For your original problem here (top of the page), you should use the skeleton application, declare two variables of the type "double" (celsius and farenheit), then take farenheit from the system input, then caclulate calsius variable value using the given formula and then write the result to the system output.
If you have trouble understanding any of the given hints - ask :-)
Greetings,
</ntr> :)

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
-
How to read an integer value from the system input (SHORT VERSION, terminate application on invalid input):
int inputAsIntegerValue;
System.out.print( "Please enter an integer value: " );
try
{
inputAsIntegerValue = Integer.parseInt( System.in.readln() );
}
catch( NomberFormatException e )
{
System.out.println( "That is not a valid int value!" );
System.exit( 0 );
}
System.out.println( "The value is "+inputAsIntegerValue );
-
How to read a floating-point number (of the type "double") from the system input (SHORT VERSION):
int inputAsDoubleValue;
System.out.print( "Please enter a double value: " );
try
{
inputAsDoubleValue = Double.parseDouble( System.in.readln() );
}
catch( NomberFormatException e )
{
System.out.println( "That is not a valid double value!" );
System.exit( 0 );
}
System.out.println( "The value is "+inputAsDoubleValue );
-
Greetings,
</ntr> :)






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
-
Let's say you know where is your JRE directory, and that you can see that there is a LIB directory inside it. If you look there, you'll see that there is a file RT.JAR in that LIB directory.
Before you can RUN/COMPILE your something.java source files you must set an environment variable:
(WinXX)
SET CLASSPATH =full path to your JRE\LIB\RT.JAR file
Example:
SET CLASSPATH=c:\jdk131\jre\li
(Linux*)
export CLASSPATH=full path to your JRE/LIB/RT.JAR file
Example:
export CLASSPATH=~/jdk131/jre/lib
-
Now, let's say you've saved your Java application (just one class, like the skeleton given in the previous post) in the file MyApplication.java
(Note: class name must match filename)
-
first you compile the class like this:
javac MyApplication.java
-
then you run the app like this:
java MyApplication
-
'Hope this helps :-)
Greetings,
</ntr> :)
Which class isn't found?
Go to the directory where the class file is and try a
java -classpath . FahrToCels

Get a FREE t-shirt when you ask your first question.
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
(you must include the current directory too)
Like this:
(WinXX)
SET CLASSPATH=c:\jdk131\jre\li
(Linux*)
export CLASSPATH=~/jdk131/jre/lib
Greetings,
</ntr> :)
I believe it was an honest mistake... in fact Neutron's tips are very useful. Many thanks, Neutron.
Cheers






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
That happens to me every time when I write some code, but when I pass the compiler syntax-check usually the rest works fine
to Emms: it was my pleasure :-)
Greetings,
</ntr> :)
Programming
--
Questions
--
Followers
Top Experts
Programming includes both the specifics of the language you’re using, like Visual Basic, .NET, Java and others, but also the best practices in user experience and interfaces and the management of projects, version control and development. Other programming topics are related to web and cloud development and system and hardware programming.