(java) найти ошибки в коде.

import java.util.Scanner:

private class Main {
import java.util.Scanner:

private class Main {
public static void main(String args) {

char operator;
Double number1, number2, result;

Scanner input = new Scanner(System.in);

System.out.print("Choose an operator: +, -, *, or /");
operator = input.next().charAt(0);

// ask users to enter numbers
System.out.print("Enter first number");
number1 = input.nextDouble();

System.out.println("Enter second number");
number2 = input.nextDouble();

switch (operator) {

// performs addition between numbers
case '+':
result = number1 + number2;
System.out.println(number1 + " + " + number2 + " = " + result);
break;

// performs subtraction between numbers
case '-':
result = number1 - number2;
Please enter comments
Please enter your name.
Please enter the correct email address.
You must agree before submitting.

Answers & Comments


Copyright © 2024 SCHOLAR.TIPS - All rights reserved.