Write a program to enter two numbers and perform mathematical operations on them

oppj program 3

Write a program to enter two numbers and perform mathematical operations on them

Explanation:

Hello friends so you have to Write a program to enter two numbers and perform mathematical operations on them

so how you are going to write java program to perform mathematical operations let’s see the logic going use behind this program

you have to perform mathematical operations and the basic mathematical operations are ( – , *)

First you have to take user input using Scanner class  and store it in two different integer variables “number1” and “number2”

then create three more integer variables to store addition, subtraction, multiply of two numbers and the variables names are “add” , “sub” , “mul”

and create one Float variable to store division of two variables and the variable name is “div”

first perform addition of two numbers and store the result in “add” variable [Ex: add = number1 +number2;]

Now perform subtraction of two numbers and store the result in “sub” variable [Ex: sub = number1 +number2;]

then perform multiplication of two numbers and store the result in “mul” variable [Ex: mul = number1 +number2;]

then perform divison of two numbers and store store the result in “div” variable [Ex: div = number1 +number2;]

and now print all the variables with their corresponding operations using System.out.println();   [Ex: System.out.println(“Sum of two number : “+add); ]

program is given below follow it for reference

if you like the the way of explanation tell us in comment section you can also write the queries about this program we are defiantly going reply

share this post with your college friends so everyone can get benefit of it

Program As per GTU Syllabus

 

OUTPUT :
practical 3

You May Also Like

About the Author: TheCoder

Leave a Reply

Your email address will not be published. Required fields are marked *