❓ Help Java Challenge

Status
Not open for further replies.

SUNRAI

Eternal Poster
Meron po bang mas okay na paraan para gawin to?
Kaylangan po kasi from 1896 Hanggang sa every 4 years yung code

Java:
/*
Olympic games is held every four (4) years at Olympia. Make a Java program that allow you input a year and tell you that year is Olympic games.
 */
package olympics;

import java.util.Scanner;

public class Olympics {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        
        /* Input year from user */
        System.out.print("Is there an olmpic in this year?: ");
        float Y = in.nextFloat();
        
         if (Y == 1896) {
            System.out.println("YES!");
            } else if (Y == 1890) {
             System.out.println("YES!");
            } else if (Y == 1894) {
           System.out.println("YES!");
            } else if (Y == 1898) {
           System.out.println("YES!");
            } else if (Y == 1902) {
           System.out.println("YES!");
            } else if (Y == 1906) {
           System.out.println("YES!");
            } else if (Y == 1910) {
           System.out.println("YES!");
            } else if (Y == 1914) {
           System.out.println("YES!");
            } else if (Y == 1918) {
           System.out.println("YES!");
        } else {
            System.out.println("NOPE");

        }
      
    }
}
 
Status
Not open for further replies.

About this Thread

  • 0
    Replies
  • 570
    Views
  • 1
    Participants
Last reply from:
SUNRAI

Online now

Members online
1,068
Guests online
821
Total visitors
1,889

Forum statistics

Threads
2,276,991
Posts
28,973,649
Members
1,229,682
Latest member
JhayPureno13
Back
Top