Chapter 5

package aaa;


import java.util.Scanner;


public class AK3 {
public static void main(String[] args) {
Scanner input =new Scanner(System.in);
               System.out.println("Please enter the first operand :");
               double opp1 =input.nextDouble();
               System.out.println("Please enter the second operand");
               if (input.hasNextDouble()==true);
               System.out.println("Please Input: 1 addition, 2 subtraction, 3 multiplication, 4 division");
               int opp2 =input.nextInt();
               int onn =input.nextInt();
               switch (onn) {
case 1 :
System.out.println("Calculate Result: "+(opp1+opp2));
break;
case 2 :
System.out.println("Calculation result: "+(opp1-opp2));
                break;
case 3 :
System.out.println("Calculation result: "+(opp1*opp2));
break;
case 4 :
System. out.println("Calculation result: "+(opp1/opp2));
   break;
default:
System.out.println("Please enter the correct number!");
break;
}
} }

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325807061&siteId=291194637