Exit Status 1 (JAVA)

import java.util.*;
class TemperatureC
    public static void main(String[] args) 
        Scanner sc = new Scanner(System.in);
        System.out.println("Enter 1 for Celcius to Fahrenheit : ");
        System.out.println("Enter 2 for Fahrenheit to Celcius : ");
        System.out.println("Enter your choice :");
        int ch = sc.nextInt();
        switch (ch) {
            case 1:
                System.out.println("Enter Temperature in Celcius : ");
                double Cel = sc.nextDouble();
                double Far = ((Cel * 9) / 5) + 32;
                System.out.println("Temperature in Fahrenheit : " + Far);
            case 2:
                System.out.println("Enter Temperature in Fahrenheit : ");
                double far = sc.nextDouble();
                double cel = ((far - 32) * 5) / 9;
                System.out.println("Temperature in Celcius : " + cel);
                System.out.println("Invalid choice entered.");

What is wrong here?
The same code is running everywhere else than Replit, why?

If you look at the errors, Replit isn’t actually reading that file, it’s reading Main.java instead. Try following these steps to change the file Replit tries to run:

Just click the next to “Files” then click “Show hidden files”. Next click on the .replit file and finally you can change the entrypoint to whatever file you want to run.

You can also change the second line from run="run_command_for_lang main.java" to run="run_command_for_lang fileIWantToRun.java", though it won’t have an effect for languages with interpreters as shown in the comment on line 1.



Show hidden files


Also see the docs on how to configure a Repl: https://docs.replit.com/programming-ide/configuring-repl

1 Like