Thursday 17 July 2014

Calculated Value Entered By User Using Java Program

import java.util.Scanner;
class first
{
    Scanner sc = new Scanner(System.in);
    void Add()
    {   
        int a,b,c;
        System.out.println("Enter the Value of A:");
        a=sc.nextInt();
        System.out.println("Enter the value of B:");
        b = sc.nextInt();
        c=a+b;
        System.out.println(c);
    }
    void Minus()
    {
        int x,y,z;
        System.out.println("Enter the value of X:");
        x=sc.nextInt();
        System.out.println("Enter the value of Y:");
        y=sc.nextInt();
        z = x-y;
        System.out.println(z);
    }
    void Mul()
    {
        int a,b,c;
        System.out.println("Enter the value of A:");
        a = sc.nextInt();
        System.out.println("Enter the value of B:");
        b = sc.nextInt();
        c=a*b;
        System.out.println(c);
       
       
    }

void Div()
    {
        int a,b,c;
        System.out.println("Enter the value of A:");
        a = sc.nextInt();
        System.out.println("Enter the value of B:");
        b = sc.nextInt();
        c=a/b;
        System.out.println(c);
       
       
    }

void Mod()
    {
        int a,b,c;
        System.out.println("Enter the value of A:");
        a = sc.nextInt();
        System.out.println("Enter the value of B:");
        b = sc.nextInt();
        c=a%b;
        System.out.println(c);
       
       
    }
   
}
class second
{
    public static void main(String args[])
    {
        first f = new first();
        f.Add();
        f.Minus();
        f.Mul();
        f.Div();
        f.Mod();
    }
}

OutPut


0 comments:

Post a Comment

Followers