Showing posts with label calculate SquareRoot of a no. Show all posts
Showing posts with label calculate SquareRoot of a no. Show all posts

Saturday, 14 December 2019

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 :


Thursday, 12 December 2019

Write a java program to calculate sum of digit .

Program :

class Sum
{
public static void main(String[] args) {
int x = 123 , Sum = 0 ;

int rem ;
while(x>0)
{
rem = x%10 ;

Sum = Sum + rem ;

x = x/10 ;
}

System.out.println("Sum is "+Sum);
}
}

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