|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
I am working on a programming project. I have been stuck for several days.I am including what I have so far and what I am trying to do any help with this would be greatly appreciated.
Write a program that allows the user to convert either from degrees Celsius to Fahrenheit or from degrees Fahrenheit to Celsius. Use the following formulas: degreesC = 5(degreesf - 32)/9 degreesF = (9(degreesC)/5) + 32 Promt user to enter a temperature and either a 'C' or 'c' for Celsius or an 'F' or 'f' for Fahrenheit allow either uppercase or lowercase and if anything other than that print an error message. Convert the temperature to Fahrenheit if Celsius is entered or Celsius to Fahrenheit is entered. Below is what I have. I am not sure where I am messing up: // Convert either Fahrenheit or Celsuis formulas publicclass ConvertDegrees2 { publicstaticvoid main (String[] args) { char answergiven =' '; int DegreesF = 00; int DegreesC = 00; int orgDegreesF = 00; int orgDegreesC = 00; System.out.println("Enter a temperature: "); System.out.println("Enter 'c' or 'f':"); answergiven = SavitchIn.readLineNonwhiteChar(); if((answergiven=='F')||(answergiven=='f')); answergiven = SavitchIn.readLineNonwhiteChar(); DegreesF = 9*(DegreesC)/5 + 32; DegreesF = SavitchIn.readLineInt(); orgDegreesC = DegreesC; if ((answergiven=='C')||(answergiven=='c')); answergiven = SavitchIn.readLineNonwhiteChar(); DegreesC = 5*(DegreesF - 32)/9; DegreesC = SavitchIn.readLineInt(); // System.out.println(orgDegreesF + "Degrees in Fahrenheit = " + DegreesC + " Degrees Celsius "); System.out.println(orgDegreesC + "Degrees in Celcius = " + DegreesF + "Degrees Fahrenheit "); System.out.println("Press 'Q' or 'q' to quit or any key to repeat program."); } } |
|
#2
|
||||
|
||||
|
Where's the problem?
|
|
#3
|
||||
|
||||
|
You might want spaces between publicclass as well as publicstaticvoid...
I assume that happened when you colorized your post. I do see further problems, but as this is a school assignment I think its better for you to spot them on your own... I'm willing to guide you, but I won't give you the solution. What happens when you run your code? |
![]() |
| Viewing: Dev Articles Community Forums > Programming > Java Development > java help |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|