JAVA

Report
Question

Please briefly explain why you feel this question should be reported .

Report
Cancel

Consider the following program that creates an object of the Arithmetic class. The Arithmetic class contains the appropriate methods to perform the arithmetic operations. Based on the program below, develop the complete Arithmetic class using JAVA.

 

class TestArithmetic {

 

public static void main (String[] args){

 

Scanner console= new Scanner (System.in);

    

     System.out.println(“Enter first number”);
int x1 = console.nextInt();

     System.out.println(“Enter second number”);
int x2 = console.nextInt();

     System.out.println(“Enter third number”);
int x3 = console.nextInt();

 

System.out.println(“x1=”+x1);

System.out.println(“x2=”+x2);

System.out.println(“x3=”+x3);

 

Arithmetic ar = new Arithmetic();

 

int answer1=ar.sum(x1,x2);

int answer2=ar.sum(x1,x2,x3);

int answer3=ar.substract(x1,x2);

double answer4=ar.divide(x1,x2);

int answer5=ar.modulas(x2,x3);

int answer6=ar.multiply(x2, x3);

int answer7= ar.largest(x1, x2, x3);

boolean evenNumber1= ar.isEvenNumber(x2);

boolean evenNumber2= ar.isEvenNumber(x3);

 

 

System.out.println(“Sum of x1 and x2 is “+answer1);

System.out.println(“Sum of x1, x2, x3 is “+answer2);

System.out.println(“Subtraction of x1 and x2 is “+answer3);

System.out.println(“Division of x1 and x2 is “+answer4);

System.out.println(“Modulas division of x2 and x3 is “+answer5);

System.out.println(“Multiplication of x2 and x3  is “+answer6);

System.out.println(“Largest value among x1, x2 and x3  is “+answer7);

if (evenNumber1)

System.out.println(“x2 is an even number”);

else

System.out.println(“x2 is an odd number”);

 

if (evenNumber2)

System.out.println(“x3 is an even number”);

else

System.out.println(“x3 is an odd number”);

 

}

}

0
Java 1 week 0 Answer 54 views 0

Leave an answer

Browse

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>