Page 186 - CA_Blue( J )_Class9
P. 186
Program 8 Write a program to check if a number is divisible by another number.
1 import java.util.Scanner;
2 class Divisibility
3 {
4 public static void main(String args[])
5 {
6 boolean result;
7 Scanner input = new Scanner(System.in);
8 System.out.print("Enter the first number: ");
9 int num1 = input.nextInt ();
10 System.out.print("Enter the second number: ");
11 int num2 = input.nextInt ();
12 if(num1%num2 == 0)
13 {
14 System.out.println(num1+" is divisible by "+num2);
15 }
16 else
17 System.out.println(num1+" is not divisible by "+num2);
18 }}
You will get the following output:
Write a program to take a student’s details marks and calculate the total marks, percentage,
Program 9
and grade of the student.
1 import java.util.*;
2 class student_detail
3 {
4 public static void main(String args[])
184 Touchpad Computer Applications-IX

