Showing posts with label scanner class. Show all posts
Showing posts with label scanner class. Show all posts

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 :




Friday, 13 December 2019

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 demonstrate increment and decrement Operator

 Program :

class IncDec
{
    public static void main(String[] args) {

        int a , b ;

        a = 2 ;
        b = 3 ;

        a++ ;
        ++a ;
        System.out.println("Value of after increment " +a) ;

        --b ;
        b-- ;
        System.out.println("Value of after decrement " +b) ;
    }
}


Output :


Write a java program to find the greatest among Three Number

 Program :

class GreatestThree
{
    public static void main(String[] args) {
        int x = 5 , y = 7 , z = 9 ;

if(x > y && x > z)
System.out.println("x is Greatest");

else
            if(y > x && y > z)
System.out.println("Y is Greatest");

else
System.out.println("Z is Greatest");   
        }
    }

Output :


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

 Program :

import java.lang.Math ;
public class Expo
{
    public static void main(String[] args) {
        System.out.println("Exponential       Value of 709.7822 is"+Math.exp(709.7822)) ;
    }
}

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 = ...