Ste Posted February 10, 2005 Posted February 10, 2005 I have an assignment for programming 1, and the instructions are to make a program where the user can input any number in degrees celsius, and have the program convert it into fahrenheit. So far this is all I have and i don't know where to go from there. /* Steven Borchard Tempature input */ import javax.swing.JOptionPane; public class TrivialApplication { public static void main(String args[]) { String firstNumber= JOptionPane.show.InputDialog("Enter a tempature in Degrees Celeius to convert into Degrees Fahrenheit"); } } any ideas? Share this post Link to post Share on other sites More sharing options...
Muddy Posted February 10, 2005 Posted February 10, 2005 find the formula for teh conversion its just multiplying and dividing Share this post Link to post Share on other sites More sharing options...
red930 Posted February 10, 2005 Posted February 10, 2005 the equation is F= (9/5)xCelsius+32 Share this post Link to post Share on other sites More sharing options...
Ste Posted February 10, 2005 Posted February 10, 2005 yes the formula is Fahrenheit=(9/5) * Celsius (the input from user) + 32 heres my progress. /* Steven Borchard Tempature input */ import javax.swing.JOptionPane; public class TrivialApplication { public static void main(String args[]) { String firstNumber= JOptionPane.show.InputDialog("Enter a tempature in Degrees Celeius to convert into Degrees Fahrenheit"); int celsius= Integer.parseInt( firstNumber ); int num1= 9; int num2= 5; int num3= 32; } } Share this post Link to post Share on other sites More sharing options...
cchalogamer Posted February 10, 2005 Posted February 10, 2005 (edited) yeah it wa one of our 1st java assignments, just parse double that string you took in, once you get that apply the formula to the number you get then i suppose your suposed to print the result correct? EDIT: any reason you stored the formula stuff in variables? why not jsut hard code the formula...it wont change. oh and use parseDouble() instead bc if not and you work with it you will loose the percision. you are goign to want the values to a Decimal now arent you . Edited February 10, 2005 by cchalogamer Share this post Link to post Share on other sites More sharing options...
Ste Posted February 10, 2005 Posted February 10, 2005 Uhhhh um hard code? Share this post Link to post Share on other sites More sharing options...
cchalogamer Posted February 10, 2005 Posted February 10, 2005 (edited) as in: double result = ((9/5) * celsius) + 32; granted more ( ) than u need but i tend to do that EDIT: ok i hope u understand that bc MY AP comp. Sci. class is about to start. im actually in there...well here....now. Edited February 10, 2005 by cchalogamer Share this post Link to post Share on other sites More sharing options...
Ste Posted February 10, 2005 Posted February 10, 2005 Im so lost. Share this post Link to post Share on other sites More sharing options...
cchalogamer Posted February 10, 2005 Posted February 10, 2005 (edited) crap your still lost lol ok add double result = ((9/5) * celsius) + 32; System.out.println("In Deg. F " + result); (actually use the other output stuff you use lol forgot we do everything in console to make it a little less frustrating lol) and it should print out the answer... you dont nees to code variables for all the numbers you use in a formula. it's a waste of time and effort. EDIT: Well i hope that helps you, just finished our quiz. If you think your lost now just wait until you get to Classes/Objects/static arrays/ArrayLists/stacks torture i tell you Edited February 10, 2005 by cchalogamer Share this post Link to post Share on other sites More sharing options...
drewkivela Posted February 10, 2005 Posted February 10, 2005 looks like you guys are doing his homework for him, does anyone speak korean so they can do mine? -drew Share this post Link to post Share on other sites More sharing options...
Ste Posted February 10, 2005 Posted February 10, 2005 Well, it would be that easy except I have to understand it, i have tommorows class period to finish it. though. Share this post Link to post Share on other sites More sharing options...
Nemo Posted February 10, 2005 Posted February 10, 2005 Someone asked about this same problem using VB a while back. Search the Programmers Corner forum for it and see if there is anything in there that helps you. Share this post Link to post Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now