Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create an application that can add, minus, multiply and divide 2 integer numbers

ID: 3882963 • Letter: C

Question


Create an application that can add, minus, multiply and divide 2 integer numbers and add, minus, multiply and divide 2 decimal numbers. For each operation, the application should allow users to enter 2 different numbers and the output should be exact as requested where the decimal results should be format with one decimal digit (see the picture rightarrow) After finishing all the operations, display the message box as below: B. INSTRUCTION HOW TO DO THE LAB To do the lab you should follow the following steps:

Explanation / Answer

Hi,
here is the fully executable code,

/* package whatever; // don't place package name! */

import java.util.*;

import java.lang.*;

import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */

class Ideone

{

public static void main (String[] args) throws java.lang.Exception

{

Scanner sc = new Scanner(System.in);

int a,b;

System.out.println("Enter first integer number");

a=sc.nextInt();

System.out.println("Enter second integer number");

b=sc.nextInt();

System.out.println("Add 2 integer numbers");

System.out.println(a+" + "+b+" ="+(a+b));

System.out.println("Enter first integer number");

a=sc.nextInt();

System.out.println("Enter second integer number");

b=sc.nextInt();

System.out.println("subtract 2 integer numbers");

System.out.println(a+"- "+b+" ="+(a-b));

System.out.println("Enter first integer number");

a=sc.nextInt();

System.out.println("Enter second integer number");

b=sc.nextInt();

System.out.println("multiply 2 integer numbers");

System.out.println(a+" * "+b+" ="+a*b);

System.out.println("Enter first integer number");

a=sc.nextInt();

System.out.println("Enter second integer number");

b=sc.nextInt();

System.out.println("divide 2 integer numbers");

System.out.println(a+" / "+b+" ="+a/b);

  

float c,d;

System.out.println("Enter first decimal number");

c=sc.nextFloat();

System.out.println("Enter second decimal number");

d=sc.nextFloat();

System.out.println("Add 2 decimal numbers");

System.out.println(c+" + "+d+" ="+(c+d));

System.out.println("Enter first decimal number");

c=sc.nextFloat();

System.out.println("Enter second decimal number");

d=sc.nextFloat();

System.out.println("subtract 2 decimal numbers");

System.out.println(c+"- "+d+" ="+(c-d));

System.out.println("Enter first decimal number");

c=sc.nextFloat();

System.out.println("Enter second decimal number");

d=sc.nextFloat();

System.out.println("multiply 2 decimal numbers");

System.out.println(c+" * "+d+" ="+c*d);

System.out.println("Enter first decimal number");

c=sc.nextFloat();

System.out.println("Enter second decimal number");

d=sc.nextFloat();

System.out.println("divide 2 decimal numbers");

System.out.println(c+" / "+d+" ="+c/d);

System.out.println("we have finished math operations");

}

}
Thumbs up if this was helpful, otherwise let me know in comments. Good Day.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote