Labels

Showing posts with label Core Java. Show all posts
Showing posts with label Core Java. Show all posts

Sunday, August 6, 2017

Find the second smallest among three numbers

import java.util.*;
public class Prog{
public static void main(String... args){
       Scanner in = new Scanner(System.in);
       int a,b,c,d,e;
       System.out.print("Enter 1st num: ");
       a = in.nextInt();
       System.out.print("Enter 2nd num: ");
       while((b=in.nextInt())==a){
             System.out.print("Duplicate.. Try again : ");
       }
       System.out.print("Enter 3rd num: ");
       while((c=in.nextInt())==b || c ==a){
               System.out.print("Duplicate.. Try again : ");
        }
        d = Math.min(a,b);
        e = Math.max(d,c);
        System.out.println(+e);
    }
}

Tuesday, February 17, 2015

Random Number

Write a java program to generate random number. Also write the same to generate random number between given range.

Watch the solution

Monday, February 2, 2015

3. Hello Name - 2

3. Write a program in java to print "Hello Name" using command line argument with taking care of possible runtime exception.
Solution

2. Hello Name

2. Write a program in java to print "Hello Name" where Name will be passed as command line argument at run time.
Solution

1. Hello World

1. Write a program in java to print or display "Hello World".
Solution