vendredi 11 septembre 2020

Else-if statement in Java is not working, what am I doing wrong?

So I'm trying to do a simple code with an if-else-if statement, but it isn't working. I have only done if-else before and I am getting confused. Here is the code. Why isn't it accepting my else-if?

import java.util.Scanner;

public class DaysOfWeek {
public static void main (String[]args) {
    Double day;
    System.out.print("Enter the day: ");
    Scanner sc = new Scanner(System.in);
    day = sc.nextDouble();
    if (day.equals("Monday"));
    {
        System.out.println("Sounds like someone has a case of the Mondays!");
    }
    else if (day.equals("Wednesday"));
    {
        System.out.println("It's hump day! El ombligo!");
    }
    else if (day.equals("Friday"));
    {
        System.out.println("Finally. It's Friday!");
    }
    else {System.out.println("It's another day of the week.");}
}}

Aucun commentaire:

Enregistrer un commentaire