❓ 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
  • 576
    Views
  • 1
    Participants
Last reply from:
SUNRAI

Trending Topics

Online now

Members online
1,026
Guests online
1,553
Total visitors
2,579

Forum statistics

Threads
2,294,906
Posts
29,093,924
Members
1,206,608
Latest member
soechi
Back
Top