Добавил:
homeworkwizard
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:lab5
.java import java.util.Scanner;
class Progal {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.print("First resistance value (Ohm): ");
float first_value = in.nextFloat();
System.out.print("The value of the second resistance (Ohm): ");
float second_value = in.nextFloat();
System.out.print("Connection type (1-serial, 2-parallel): ");
int ctype = in.nextInt();
if (ctype == 1) {
double res;
res = first_value + second_value;
System.out.printf("Circuit resistance: " + res);
}
else if (ctype == 2) {
double res;
res = ((first_value * second_value) / (first_value + second_value));
System.out.printf("Circuit resistance: " + res);
}
else {
System.out.printf("Choose the right number 1 or 2");
}
in.close();
}
}
class Progal {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.print("First resistance value (Ohm): ");
float first_value = in.nextFloat();
System.out.print("The value of the second resistance (Ohm): ");
float second_value = in.nextFloat();
System.out.print("Connection type (1-serial, 2-parallel): ");
int ctype = in.nextInt();
if (ctype == 1) {
double res;
res = first_value + second_value;
System.out.printf("Circuit resistance: " + res);
}
else if (ctype == 2) {
double res;
res = ((first_value * second_value) / (first_value + second_value));
System.out.printf("Circuit resistance: " + res);
}
else {
System.out.printf("Choose the right number 1 or 2");
}
in.close();
}
}
Соседние файлы в предмете Программирование на Java