Friday, 24 January 2020

Write a java program to input marks of 5 student if 5 subject out of 100 marks each , output sum and percentage of marks and appropriate division i.e distigusion first class upto fail


Programe :

import java.util.*;

class Student

{

public static void main(String args[]) 

  {   

Scanner s = new Scanner(System.in);

int M , E , A , S , G , Total; float percentage ;


System.out.println("Enter the marks of 5 subject :");

M = s.nextInt();

E = s.nextInt();

                    A = s.nextInt();

                     S = s.nextInt();

G = s.nextInt();


Total = M + E + A + S + G ;

                     System.out.println("Total is : " +Total);


percentage = (Total * 100) /500;

System.out.println("Percentage is :" +percentage);


if (percentage >= 90 )

                      System.out.println(" First class ");


else if (percentage >= 65 ) 

System.out.println(" Second Class ");


                       else if ( percentage >= 40)

                       System.out.println(" Third Class ");


                       else

                       System.out.println(" Fail ");   

 }

}


Output :




Saturday, 14 December 2019

Write a java program to swap a two integer without using a Temporary Third variable

Program :
class Swap1
{
    public static void main(String[] args) {
       
        int x = 5 ;
        int y = 7 ;

        x = x +  y ;
        y =  x - y ;
        x = x - y ;

        System.out.println("After Swapping " +x);
        System.out.println("Before Swapping " +y);

    }
}

Output :


Write a java program to swap a two integer using third variable Temporary.

Program :

class Swap
{
    public static void main(String[] args) {
       
        int x = 5 ;
        int y = 7 ;
        int temp ;
        temp = x ;
        x = y ;
        y = temp ;

        System.out.println("After Swapping " +x);
        System.out.println("Before Swapping " +y);

    }
}

Output :


Friday, 13 December 2019

write a java program to demonstrate used of Math Function round()

 Program :

import java.lang.Math ;
public class RoundFun
{
    public static void main(String[] args) {
       
        double d1 = 201.653 ;
        System.out.println("Round value of d1 : " +Math.round(d1)) ;   
    }
}

Output :


write a java program to demonstrate used of Math Function pow()

Program :

import java.lang.Math ;
public class Power
{
    public static void main(String[] args) {
        double n1 = 2 , n2 = 3;

        System.out.println(+n1 + " ^ " + n2 + " = " +Math.pow(n1 , n2 ));
    }
}

Output :


write a java program to find the smallest of two value using Math Function min()

Program :

import java.lang.Math ;
public class Minimum
{
    public static void main(String[] args) {
        int n1 , n2 ;

n1 = 3 ;
n2 = 4 ;

        System.out.println("Manimum of " + n1 +" and " + n2 + " is " + Math.min(n1 , n2)) ;

    }
}

Output :



write a java program to find the largest of two value using Math Function max()

Program :

import java.lang.Math ;
public class Maximum
{
    public static void main(String[] args) {  
 
        int n1 , n2 ;

        n1 = 3 ;
        n2 = 4 ;

        System.out.println("Maximum of " + n1 +" and " + n2 + " is " + Math.max(n1 , n2)) ;

    }
}

Output :


Write a java program to input marks of 5 student if 5 subject out of 100 marks each , output sum and percentage of marks and appropriate division i.e distigusion first class upto fail

Programe : import java.util.*; class Student { public static void main(String args[])     {     Scanner s = ...