Question: Hi all, I think I have this Temperature Conversion program from Java almost right, but the only error message I'm getting when I run the

Hi all,

I think I have this Temperature Conversion program from Java almost right, but the only error message I'm getting when I run the program is "TemperatureConversion.java:31: error: illegal start of expression private static double CelsiusToFahrenheit(double Celsius); ^ 1 error". I understand that this error most likely has something to do with my use of curly brackets, but I've tried tweaking various times, with no luck.

The directions are " Modify the program and create two methods to convert from Celsius to Fahrenheit and vice versa. public static double CelsiusToFahrenheit (double Celsius) public static double FahrenheitToCelsius (double Fahrenheit) "

This is what I have so far: (this code gave me no problems in netbeans, but isn't working out as well in my online textbook for my Java course)

import java.util.Scanner; public class TemperatureConversion { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); char convertFrom = 'C'; { do { System.out.println("Convert from degree C, enter C; Convert from degree F, enter F: "); convertFrom = Character.toUpperCase(scnr.next().charAt(0)); } while (!((convertFrom == 'C') || (convertFrom == 'F'))); System.out.println("Enter degree in " + convertFrom + ": "); switch (convertFrom) { case 'C': System.out.println("Enter the degree in Celsius"); double C= scnr.nextDouble(); double CF= CelsiusToFahrenheit(C); System.out.println("Celsius degree in Fahrenheit is :"+ CF); break; case 'F': System.out.println("Enter the degree in Fahrenheit"); System.out.println("Enter the degree in F"); double F=scnr.nextDouble(); double FC= FahrenheitToCelsius(F); System.out.println("Fahrenheit degree in Celsius is :"+ FC); break; } private static double CelsiusToFahrenheit(double Celsius); { double f=0.0; f = Celsius * 9/5 + 32; return f; } private static double FahrenheitToCelsius (double Fahrenheit); { double c=0.0; c = (Fahrenheit-32)*(0.5556); return c; }

}

Hi all, I think I have this Temperature Conversion program from Java

1 import java.util.Scanner; 2 public class TemperatureConversion 3 public static void main (String[] args) f 4 Scanner scnr = new Scanner(System.in); char convertFrom"C'; do System.out.println("Convert from degree C, enter C; Convert from degree F, enter F: ") convertFromCharacter.toUpperCasescnr.next ).charAt (0)); 9 while ((convertFrom 'C (convertFrom'F))) System.out.print 1n ("Ent er ?n "); 12 13 " degree + convert F ron + ": switch (convertFrom) case 'C': System.out.println("Enter the degree in Celsius") double C-scnr.next Double); double CF-CelsiusToF ahrenheit(C); System.out. print 1n ("Celsius degree in Fahrenheit ?s :.. + CF); break; 17 20 case 'F' System.out.print 1n("Ent er the degree ?n Fahrenheit"); System.out.print 1n("Ent er the degree ?n F"); double F-scnr.nextDouble); double FC FahrenheitToCelsius (F); System.out.print 1n ("Fahrenheit degree in Celsius ?S :"+ FC); break; 23 25 27 28 private static double Celsius ToFahrenheit (double Celsius); double f 0. 0; return f; 30 32 33 f Celsius * 9/5 32; 34 36 private static double FahrenheitToCelsius (double Fahrenheit) 37t double C-0. 0; 39 C(Fahrenheit -32)*(0.5556); 40 return c

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!