Right, I'm doing some university work, and I've got this message a few times but it just isn't going away with this program. Can someone please help with the static and non-static referencing for variables please? I have looked at the other posts in reference to this problem and it's still not helping with this piece of code
import java.util.*; public class temperatureConverterMenu { public Scanner sc = new Scanner(System.in); char choice; double centigrade, farenheit; public void menu() { Scanner sc = new Scanner(System.in); System.out.println("Please choose from the following menu..."); System.out.println("To enter a centigrade value to convert to farenheit enter 1"); System.out.println("To enter a farenheit value to convert to centigrade enter 2"); System.out.println("Please enter -1 to quit the program"); System.out.println("------------- * -------------"); choice = sc.next().charAt(0); do{ switch (choice) { case '1': { System.out.println("You have chosen centigrade to farenheit"); System.out.println("Please enter your centigrade value:"); centigrade = sc.nextDouble(); centigradeToFarenheit(centigrade); break; } case '2': { System.out.println("You have chosen farenheit to centigrade"); System.out.println("Please enter your farenheit value:"); farenheit = sc.nextDouble(); farenheitToCentigrade(farenheit); break; } default: System.out.println("You did not enter a menu option..."); break; } } while(choice != -1); } // centigrade to farenheit public void centigradeToFarenheit(double centigrade) { double Faren; Faren = (centigrade*9)/5; System.out.println(centigrade+"C is "+Faren+"F"); //return Faren; } //farenheit to centigrade public void farenheitToCentigrade(double farenheit) { double Cent; Cent = (farenheit*5)/9; System.out.println(farenheit+"F is "+Cent+"C"); //return Cent; } public static void main(String[] args) throws java.io.IOException { System.out.println("Welcome to the temperature converter"); menu(); } }
Thank you