Hi I am having problems with a college assignment
Its a celsius to Fahrenheit converter I have the first part working however the
second part of the project involves coding the converter to convert from 90 degrees celsius to 95 degrees celsius.
I figure the best way is through an if or else statement but I not sure how to work this into the code I have.
the third part of the project involves using decimal format when I try to run the decimal format the project fails.
The code for 90 degrees upwards is as follows
I guess I use an if or else statementCode:f=((9.0/5.0)*90)+32);
if 90
else 90<
like
but not sure how to work this into the codeCode:if((int)((degree - 32) * 5)/9 == 90) { System.out.println("194 degrees Fahrenheit"); } else if ((int)((194 - 32) * 5)/9 == <90 ) { System.out.println(" degrees Fahrenheit" ); }
the code for the decimal format I have is
Code:import java.text.Decimalformat; DecimalFormat oneDigit = new DecimalFormat ("0.0"); System.out.println("90"+ oneDigit.Format (f));
The following is for the code for the converter working as normal.
Any help would be greatly appreciated. thanksCode:package converter; import javax.swing.JOptionPane; public class Converter { public static void main(String[] args) { String degreestring = JOptionPane.showInputDialog("Enter a temperature in degrees Celsius:"); int degree; degree = Integer.parseInt( degreestring ); int fahrenheit; fahrenheit = (int) ((9.0 / 5.0) * degree + 32.0); JOptionPane.showMessageDialog(null, degree + " degrees Celsius = " + fahrenheit + " degress Fahrenheit"); System.exit(0); } }



Reply With Quote

Bookmarks