lundi 13 août 2018

Error shows ";" is expected in if-else statements in Java [on hold]

The code is -

import java.io.*;
import java.util.Scanner;

public class Main {
public static void main(String args[]) throws IOException{
String s;   
Scanner in = new Scanner(System.in);
System.out.println("Enter the Number of shipments per month:");
int n = in.nextInt();
s = in.nextLine();

If (n>0); {
    If (n>20); {
        System.out.println("Valuable customer");
    }
    Else {
        System.out.println("Not a valuable customer");
    }
}
Else {
    System.out.println("Invalid Input");
}

}
}

The compilation error shows - Compilation Errors Main.java:16: error: not a statement Else { ^ Main.java:16: error: ';' expected Else { ^ Main.java:20: error: not a statement Else { ^ Main.java:20: error: ';' expected Else { ^ 4 errors

Aucun commentaire:

Enregistrer un commentaire