Posts

Showing posts from April, 2021

Set Java Environment, Compile and execute sample java program to print “Hello World”.

Image
  AIM: Set Java Environment, Compile and execute sample java program to print “Hello World”.   CODE: public class hello {             public static void main(String args[])             {                         System.out.println("Hello World");             } }   OUTPUT:

Write a program in Java to generate first n prime numbers.

Image
  AIM: Write a program in Java to generate first n prime numbers.   CODE: import java.util.Scanner; public class prime {             public static void main(String args[])             {                           Scanner readme = new Scanner(System.in);                           System.out.println("Enter Number " );                         int n1;                         n1 = readme.nex...

Write a program in Java to find maximum of three numbers using conditional operator.

Image
  AIM:    Write a program in Java to find maximum of three numbers using conditional operator.   CODE: public class max {             public static void main(String args[])             {                         int n1=Integer.parseInt(args[0]);                         int n2=Integer.parseInt(args[1]);                         int n3=Integer.parseInt(args[2]);                         int ma...

Write a program to display result of student according to their marks using Switch case

Image
  AIM: Write a program to display the result of student according to their marks using Switch case   CODE: import java.util.Scanner; public class marks {             public static void main(String args[])             {                           Scanner readme = new Scanner(System.in);                           System.out.println("Enter Number " );                         int n1;                     ...

Write a program in Java to find maximum and minimum of n numbers without using arrays.

Image
  AIM: Write a program in Java to find maximum and minimum of n numbers without using arrays.   CODE: import java.util.Scanner; public class large {             public static void main(String[] args)             {                         System.out.println("l");                         System.out.println("enter value of N: ");                         Scanner readme = new Scanner(System.in);                     ...

Write a program in Java to reverse the digits of a number using while loop

Image
  AIM: Write a program in Java to reverse the digits of a number using while loop CODE: import java.util.Scanner; public class reverse {             public static void main(String args[])             {                           Scanner readme = new Scanner(System.in);                           System.out.println("Enter Number " );                         int n1,n2,ans=0;                       ...

Read One-dimensional array having 5 elements from user and add amount of 15 in each element.

Image
  AIM: Read a One-dimensional array having 5 elements from user and add amount of 15 in each element. CODE: import java.util.Scanner; public class p7 {    public static void main( String args[] )     {             Scanner readme = new Scanner(System.in);             int a[]=new int[5];             System.out.println("Enter 5 Elemenys for array\n");             for(int i=0;i<5;i++)             {                                     a[i] = readme.nextInt();         ...