Answer to Question #260893 in HTML/JavaScript Web Application for ammar

Question #260893

6. Write a program that asks the user for two numbers, then lets the user choose the using 4

buttons, one for each operation. (+, -, *, / )The program should do the requested operation and

display the answer on the screen.

7. Modify program 6 to do the same thing using a dropdown menu and an = button to execute.

Use <select> <option></option></select> for your dropdown. Only java plz


1
Expert's answer
2021-11-04T00:24:07-0400
import java.util.Scanner;
 
public class Exercise6 {
 
 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));
 }
 
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS