Computer Science, asked by kaurtamanna2000, 9 days ago

Create a math program that will ask the user to enter in any two numbers. The numbers will then be added, subtracted, multiplied and divided. The result of each will be displayed to the screen. Note – each of the mathematical operations must be completed using a function that you create. The function must NOT make use of global variables. The functions must return a value. You must ensure that the higher number is always subtracted from and divided from. Format all results to two decimal places.

Answers

Answered by kaashvi412
0

Answer:

du ur self hehehhehehehe

Answered by shilpa85475
0

The use of a switch case can be done.

Explanation:

import java.util.Scanner;

 

public class abc

{

 

public static void main(String[] args) {

 Scanner in = new Scanner(System.in);

   

 System.out.print("Input first number: ");

 int num1 = in.nextInt();

   

 System.out.print("Input second number: ");

 int num2 = in.nextInt();

   

 

 System.out.println(num1 + " + " + num2 + " = " +  

 (num1 + num2));

   

 System.out.println(num1 + " - " + num2 + " = " +  

 (num1 - num2));

   

 System.out.println(num1 + " x " + num2 + " = " +  

 (num1 * num2));

   

 System.out.println(num1 + " / " + num2 + " = " +  

 (num1 / num2));

 

 System.out.println(num1 + " mod " + num2 + " = " +  

 (num1 % num2));

}

 

}

Similar questions