- Home
- Arithmetic operators
- Basic calculator

Monday, November 13, 2023
⁃
Difficulty:
Easy

Write a program in Java that calculates the result of adding, subtracting, multiplying and dividing two numbers entered by the user.

In addition you should also calculate the rest of the division on the last line.

- Solicit two numbers from the user.
- Calculate the sum of the two numbers.
- Calculate the subtraction of the two numbers.
- Calculate the multiplication of the two numbers.
- Calculate the division of the two numbers.
- Display the result of the sum, subtraction, multiplication, and division on separate lines.
- Calculate and display the remainder of the division of the two numbers.

12 3

12 + 3= 15 12 - 3= 9 12 x 3= 36 12 / 3= 4 12 mod 3= 0

Share it on your social media and challenge your friends to solve programming problems. Together, we can learn and grow.

The code has been successfully copied to the clipboard.

Continue improving your Java programming skills with our selection of practical exercises from the lesson. Click on Practice and challenge your knowledge!

Practice with easy and intermediate Java exercises on arithmetic operations and some types of numerical data.