0% found this document useful (0 votes)
3 views5 pages

MTK Sam - Assignment1

The document contains three Java programs that perform basic arithmetic and comparison operations. Assignment1 calculates the sum, average, product, smallest, and largest of three integers. Assignment2 finds the smallest and largest among five integers, while Assignment3 checks if the first number is a multiple of the second.

Uploaded by

Zayar Kyaw Lin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views5 pages

MTK Sam - Assignment1

The document contains three Java programs that perform basic arithmetic and comparison operations. Assignment1 calculates the sum, average, product, smallest, and largest of three integers. Assignment2 finds the smallest and largest among five integers, while Assignment3 checks if the first number is a multiple of the second.

Uploaded by

Zayar Kyaw Lin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

1.

import java.util.Scanner;

public class Assignment1 {

public static void main(String[] args) {

// TODO Auto-generated method stub

Scanner input = new Scanner(System.in);

System.out.println("Enter three integers with space : ");

int num1 = input.nextInt();

int num2 = input.nextInt();

int num3 = input.nextInt();

int sum = num1 + num2 + num3;

int average = sum / 3;

int product = num1 * num2 * num3;

int smallest = Math.min(num1, Math.min(num2, num3));

int largest = Math.max(num1, Math.max(num2, num3));

System.out.println("Sum : " + sum);

System.out.println("Average : " + average);

System.out.println("Product : " + product);

System.out.println("Smallest : " + smallest);

System.out.println("Largest : " + largest);

input.close();
}

2.

import java.util.Scanner;

public class Assignment2 {

public static void main(String[] args) {

Scanner input = new Scanner(System.in);

System.out.println("Enter five number with space : ");

int num1 = input.nextInt();

int num2 = input.nextInt();

int num3 = input.nextInt();

int num4 = input.nextInt();

int num5 = input.nextInt();

int mini = Math.min(num1, Math.min(num2, Math.min(num3, Math.min(num4, num5))));

int maxi = Math.max(num1, Math.max(num2, Math.max(num3, Math.max(num4, num5))));

System.out.println("Largest number : " + maxi);

System.out.println("Smallest number : " + mini);

input.close();

}
}

3.

import java.util.Scanner;

public class Assignment3 {

public static void main(String[] args) {

Scanner input = new Scanner(System.in);

System.out.print("Enter two number with space : ");

int num1 = input.nextInt();

int num2 = input.nextInt();

if(num2 != 0 && num1 % num2 == 0) {

System.out.println("The first number is a multiple of the second number.");

else {

System.out.println("The first number is not a multiple of the second number.");

} input.close();

You might also like