CL 9 Java Programs
CL 9 Java Programs
CLASS IX
Computer Science(2022-23)
import java.util.Scanner;
public class Leap_Year {
public static void main(String[] args){
int year;
System.out.println("Enter an Year :: ");
Scanner sc = new Scanner(System.in);
year = sc.nextInt();
3. Java
program of grading system for fail, D grade, C grade, B grade, A grade and A+
.
import java.util.Scanner;
public class Grade {
public static void main(String[] args) {
printNumbers(number);
}
//Body of the user defined function
public static void printNumbers(int num)
{
//Checkinf the condition for the funtion processing
if(num <= 100)
{
//Printing the output number to the user by the program.
System.out.print(num +" ");
//Increasing the value of number by 1
printNumbers(num + 1);
}
}
}
7. Java program prints the first 10 natural numbers using a While loop.
class While {
9. Java Program to find the sum of 5 numbers entered by the user is printed.
import java.util.Scanner;
class SumOfNumbers {
10. The first 10 natural numbers are printed using a Do While Loop in Java.
class DoWhile {
do {
System.out.println(n);
n++;
} while (n <= 10);
}
}