## Java program to print greatest number

### Java Program to Find Largest Between Three Numbers Using Ternary Operator

In this program ternary operator (?, >, : ) to find the largest number as the output is used. The below program taking three numbers from the user and checked it with the ternary operator and print the greatest among the three numbers.
import java.io.*;
public class GreatestNumberUsingTernary
{
public static void main(String[] args)
{
Int a,b,c;
InputStreamReader in = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(in);
System.out.println("Enter three numbers to find greatest : ");
// Inputing three number from the user
a  =  Integer.parseInt(br.readLine());
b  =  Integer.parseInt(br.readLine());
c  =  Integer.parseInt(br.readLine());
d = c > (a > b ? a : b) ? c : ((a > b) ? a : b);
System.out.println("Greatest Number:"+d);
}
}

### Write a program to input three numbers and find the greatest of them.

In the following, we are taking three numbers from users as input and checked the number using if..else if statement and compiled and successfully print the output. We have given a simple description of the variable too.

Solution
import java.io.*;
public class GreatestNumber
{
// main method begins
public static void main (String args[]) throws IOException
{

int number1, number2, number3;
number1 = number2 = number3 = 0;

InputStreamReader in = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(in);
System.out.println("Enter three numbers to find greatest : ");
// Waiting for the user input
number1  =  Integer.parseInt(br.readLine());
number2  =  Integer.parseInt(br.readLine());
number3  =  Integer.parseInt(br.readLine());
// Checking number1 with number2 and number1 with number3
// if satisfied then print number1 as greatest.
if (number1 > number2  &&  number1 > number3)
{
System.out.println (number1 +  " is greatest");
}
// Checking number2 with number1 and number2 with number3
// if satisfied then print number3 as greatest.
else if (number2 > number1  && number2 > number3)
{
System.out.println (number2 +  " is the greatest");
}
// if above condition is not satisefied the it print number3
else
{
System.out.println (number3 +  " is the greatest");
}

} // end method main
} // end class

Sample Output
Enter three numbers to find the greatest :
9
2
5
9 is the greatest
Enter three numbers to find the greatest :
10
30
13
30 is the greatest

 SN Variables/Function Type Description 1. in object InputStreamReader object 2. br object BufferedReader object 3. number1 int First number 4. number2 int Second number 5. Number3 int Third number 6. main() User-defined Function Starting of java program

MORE ISC COMPUTER SCIENCE PROGRAM

## ISC 2016 COMPUTER PRACTICAL QUESTION 3 SOLVED

Write a program to accept a sentence which may be terminated by either '.', '?', or '!' only. The words may be separated by more than one blank space and are in UPPER CASE.
Perform the following tasks:
(a) Find the number of words beginning and ending with a vowel.
(b) Place the words which begin and end with a vowel at the beginning, following by the remaining words as they occur in the sentence.

#### Test your program with the sample data and some random data:

Example 1
Input : ANAMIKA AND SUSAN ARE NEVER GOING TO QUARREL ANYMORE.
Output : NUMBER OF WORDS BEGINNING AND ENDING WITH A VOWEL = 3
ANAMIKA ARE ANYMORE AND SUSAN NEVER GOING TO QUARREL
Example 2
Input : YOU MUST AIM TO BE A BETTER PERSON TOMORROW THAN YOU ARE TODAY
Output : NUMBER OF WORDS BEGINNING AND ENDING WITH A VOWEL = 2
A ARE YOU MUST AIM TO BE BETTER PERSON TOMORROW THAN YOU TODAY

Solution
import java.util.StringTokenizer;
import java.io.*;
public class ISC2016Practical3 {
public static void main(String a[])throws IOException
{
int i,k ,m, n, f1, f2;
char w1, w2;
i = 0;
m = 0;
n = 0;
f1 = f2= 0;

String st, word;
String words[] = new String;
String wordWithEndBeginVowel[] = new String;
String wordWithoutEndBeginVowel[] = new String;
InputStreamReader in = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(in);
System.out.println("Enter a sentence:");
st=br.readLine();
StringTokenizer st1 = new StringTokenizer(st,". , ? !");

while(st1.hasMoreTokens())
{
word = st1.nextToken();
words[i]=word;
i++;
}

for(k=0; k<i; k++)
{
f1 = f2 = 0;
switch(words[k].charAt(0))
{
case 'A':
case 'a':
case 'E':
case 'e':
case 'I':
case 'i':
case 'O':
case 'o':
case 'U':
case 'u':
f1 = 1;

}

switch(words[k].charAt((words[k].length())-1))
{
case 'A':
case 'a':
case 'E':
case 'e':
case 'I':
case 'i':
case 'O':
case 'o':
case 'U':
case 'u':
f2=1;

}
if(f1==1 && f2==1)
{
wordWithEndBeginVowel[m]=words[k];
System.out.println(words[k]);
m++;

}
else
{
wordWithoutEndBeginVowel[n]=words[k];
n++;
}

}
System.out.println("Total Words Begin and End with Vowels="+m);
System.out.println("Words Begin and End with Vowels");
for(i=0;i<m;i++)
System.out.println(wordWithEndBeginVowel[i]);
System.out.println("Words Begin and End without Vowels");
for(i=0; i<n; i++)
System.out.println(wordWithoutEndBeginVowel[i]);

}
}

Sample Output:
Enter a sentence:
ANAMIKA AND SUSAN ARE NEVER GOING TO QUARREL ANYMORE
ANAMIKA
ARE
ANYMORE
Total Words Begin and End with Vowels=3
Words Begin and End with Vowels
ANAMIKA
ARE
ANYMORE
Words Begin and End without Vowels
AND
SUSAN
NEVER
GOING
TO
QUARREL
Enter a sentence:
HAVE A NICE DAY ANA.
A
ANA
Total Words Begin and End with Vowels=2
Words Begin and End with Vowels
A
ANA
Words Begin and End without Vowels
HAVE
NICE
DAY

MORE ISC COMPUTER SCIENCE PROGRAM