Page 54 - CITS - CSA - TP (Volume 2) - Hindi
P. 54

कं  ूटर सॉ वेयर ए ीके शन - CITS


































           टा   4: जाँच  िक कोई वष  शता ी वष  है या नहीं

           import java.util.Scanner;
           public class CenturyYearCheck {

               public static void main(String[] args) {
                   // Create a Scanner object to read input from the console
                   Scanner scanner = new Scanner(System.in);

                   // Prompt the user to enter a year
                   System.out.print(“Enter a year: “);
                   // Read the integer input provided by the user

                   int year = scanner.nextInt();
                   // Check if the year is divisible by 100 and print the result
                   if (year % 100 == 0) {

                       System.out.println(year + “ is a century year.”);
                   } else {
                       System.out.println(year + “ is not a century year.”);

                   }
                   // Close the scanner object to release system resources
                   scanner.close();

               }
           }

             ीकरण:
           1    ो ाम कं सोल से उपयोगकता  इनपुट की अनुमित देने के  िलए java.util पैके ज से  ै नर  ास को आयात करके  शु  होता है।
           2   CenturyYearCheck  ास म  मु  िविध होती है, जो  ो ाम के   वेश िबंदु के   प म   ो ाम करती है।

           3   मु  िविध के  अंदर:


                                                           40

                                   CITS : IT & ITES - कं  ूटर सॉ वेयर ए ीके शन - अ ास 85
   49   50   51   52   53   54   55   56   57   58   59