Начинающий
- Статус
- Оффлайн
- Регистрация
- 21 Июл 2022
- Сообщения
- 92
- Реакции
- 1
Можете оценить мой первый небольшой проект по java. Называется "Калькулятор". Не судите строго
Код:
import java.util.Scanner;
public class Start {
public static String error = "Не правильный выбор действия";
public static String answer = "Ответ действия: ";
public static int c1 = 1;
public static String console1 = "+";
public static int c2 = 2;
public static String console2 = "-";
public static int c3 = 3;
public static String console3 = "/";
public static int c4 = 4;
public static String console4 = "*";
public static int c5 = 5;
public static String console5 = "%";
public static void main(String[] args) {
Scanner console = new Scanner(System.in);
System.out.println("Первое число:");
int first = console.nextInt();
System.out.println("Второе число:");
int second = console.nextInt();
System.out.println("Выбор действия:");
System.out.println(c1 + ": " + console1);
System.out.println(c2 + ": " + console2);
System.out.println(c3 + ": " + console3);
System.out.println(c4 + ": " + console4);
System.out.println(c5 + ": " + console5);
boolean checktrue;
int check = console.nextInt();
if (check > 5) {
System.out.println(error);
checktrue = false;
}
if (check < 5 && check > 5) {
System.out.println(error);
checktrue = true;
}
if (checktrue = true) {
System.out.println("Складываю решение...");
}
if (check == c1) {
int answer1 = first + second;
System.out.println(answer + answer1);
} else if (check == c2) {
int answer1 = first - second;
System.out.println(answer + answer1);
} else if (check == c3) {
int answer1 = first / second;
System.out.println(answer + answer1);
} else if (check == c4) {
int answer1 = first * second;
System.out.println(answer + answer1);
} else if (check == c5) {
int answer1 = first % second;
System.out.println(answer + answer1);
}
}
}