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

Java 31

The document contains a Java program that prompts the user to input three numbers and determines the greatest among them. The code utilizes the Scanner class for input and employs a conditional operator to find the maximum value. Two students, Arshan and Bhavesh Chauhan, have submitted identical code for the same task.

Uploaded by

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

Java 31

The document contains a Java program that prompts the user to input three numbers and determines the greatest among them. The code utilizes the Scanner class for input and employs a conditional operator to find the maximum value. Two students, Arshan and Bhavesh Chauhan, have submitted identical code for the same task.

Uploaded by

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

Java Lab

Arshan
2300290110042 CSIT -
4A

1. WAP to insert 3 numbers from the keyboard and find a greater number among 3
numbers
Code:

import java.util.Scanner;

public class GreatestOfThree {

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

System.out.print("Enter first number: ");

int a = sc.nextInt();

System.out.print("Enter second number: ");

int b = sc.nextInt();

System.out.print("Enter third number: ");

int c = sc.nextInt();

int greatest = (a > b && a > c) ? a : (b > c ? b : c);

System.out.println("Greatest number is: " + greatest);

Output:
Enter first number: 12
Java Lab
Bhavesh Chauhan
2300290110064
CSIT - 4A

1. WAP to insert 3 numbers from the keyboard and find a greater number among 3
numbers
Code:

import java.util.Scanner;

public class GreatestOfThree {

public static void main(String[] args) {

Scanner sc = new Scanner(System.in);

System.out.print("Enter first number: ");

int a = sc.nextInt();

System.out.print("Enter second number: ");

int b = sc.nextInt();

System.out.print("Enter third number: ");

int c = sc.nextInt();

int greatest = (a > b && a > c) ? a : (b > c ? b : c);

System.out.println("Greatest number is: " + greatest);

Output:
Enter first number: 12

You might also like