0

Keep Getting ERROR

Hi beautiful people! I have this assignment due and I cant get it to run, I keep getting: main.java: 1: error: class, interface, or enum expected Main.java ^ main.java: 301: error: class, interface, or enum expected Converter.java here is my program as of now.. Main.java import java.util.InputMismatchException; import java.util.Scanner; import java.util.ArrayList; import java.io.*; public class Main { private static class node{ String from,to; public node(String f, String t) { from = f; to = t; } public String toString() { return(from + " -> " + to); } } public static void main(String[] args) { Scanner in = new Scanner(System.in); ArrayList<node> hisList = new ArrayList<node>(); Converter con = new Converter(); while (true) { try { FileWriter myWriter = new FileWriter("error.log",true); // showing the user the Menu options System.out.println("\nMenu "); System.out.println("0. History"); System.out.println("1. Temperature Converter"); System.out.println("2. Mass Converter"); System.out.println("3. Distance Converter"); System.out.println("4. Volume Converter"); System.out.println("5. Exit the program"); // prompting the user to choose a menu option by entering its number. System.out.println("Enter the type of Conversion <1-4> : "); int option = in.nextInt(); if (option == 5) { break; } int option2; // switch statements. one of these statements will be printed out, depending on // what the user chooses. switch (option) { case 0: { for(node x : hisList) { System.out.println(x.toString()); } break; } case 1: System.out.println(" 1. Convert from Fahrenheit Celsius"); System.out.println(" 2. Convert from Fahrenheit Kelvin"); System.out.println("Enter the option <1-2> : "); option2 = in.nextInt(); switch (option2) { case 1: System.out.println("Please enter the temperature in Fahrenheit : "); double f = in.nextDouble(); double c = con.tempFahrenheitToCelcius(f); node n = new

13th May 2020, 4:15 AM
Jessica
Jessica - avatar
1 Antwort
0
Kind of hard to see the problem, but you should check name of class Main and Converter, if brackets or parentheses are properly placed or function out of the class....start with those and see if you can find the problem.
13th May 2020, 4:25 AM
Jay W