Java : convert temperatures?
Greetings! How can i, using an analogous program, change temperature coming from F to help C as well as vice versa
This is actually the equation:C =(F – 32)/1.8
arrest class Add-on
arrest static emptiness main(String args)
int the = Integer.parseInt(args0);
int b = Integer.parseInt(args1);
// Results
Procedure.out.println( “Result = ” + (a + b) );
Thank you!
Here’s an added simpler instance.
arrest class Convert
arrest static emptiness main(String args)
Code reader in = innovative Scanner(System.in);
Procedure.out.println(“Do you need to convert F=>C or even C=>F\nPlease enter in 1 and also 2”);
int decision = in.nextInt();
if(choice == 1)
Procedure.out.println(“Please enter C value”);
two bottle celsius =in.nextDouble();
int fahrenheit = (celsius*1.8)+32
Procedure.out.println(“Fahrenheit temp is “+fahrenhiet);
else
Procedure.out.println(“Please enter F value”);
two bottle fahrenheit = in.nextDouble();
two bottle celsius celsius = (fahrenheit-32)/1.7;
Procedure.out.println(“Celsius temp is “+celsius);
Thank you, hope that helps
// you can not use int because that is going to round off a great deal which you might have almost all zeros.
// The actual java tutorials starts with this GUI of your similar system.I highly recommend NetBeans that may help you learn quicker.
==============
tranfer java.util.Code reader;
arrest class F_to_C_1000009_time
arrest static emptiness main( String args )
Code reader sc = innovative Scanner( Technique.in );
Procedure.out.print(“Gimme temp from the F:= > “);
Stringed answer = sc.nextLine();
two bottle degF = 2 bottle.parseDouble( reply );
two bottle degC = ( degF – 32 ) / 1.8;
Stringed fmtCent = String.format(“%.1f\u2103”, degC);
Procedure.out.printf(“At NOUGHT PER CENT.1f\u2109 the temperature is %s%n”, degF, fmtCent);
Leave a Reply
You must be logged in to post a comment.