![]() |
Willkommen, Gast ( Anmelden | Registrierung )
![]() |
![]()
Beitrag
#1
|
|
![]() Feuerteufel ![]() ![]() ![]() ![]() ![]() ![]() Gruppe: Mitglieder Beiträge: 2.228 Mitglied seit: 22.08.2004 Mitglieds-Nr.: 1.348 ![]() |
Ich habe eine Frage, wie kann ich eine zwei If-Überprüfung in eine If-Andwendung.
Soweit bin schon, aber mir fehlt der Operator zur Verbindung der zwei Abfragen: if(ausdruck1 ausdruck2) -------------------- |
|
|
![]() |
![]()
Beitrag
#2
|
|
![]() Feuerteufel ![]() ![]() ![]() ![]() ![]() ![]() Gruppe: Mitglieder Beiträge: 2.228 Mitglied seit: 22.08.2004 Mitglieds-Nr.: 1.348 ![]() |
Bisher sieht das Programm so aus:
QUELLTEXT import java.util.Scanner;
public class TaschenRechner { public static void main(String[] args) { double x = 0; double y = 0; int a = 0; System.out.println("Für Operatoren Plus = 1, Minus = 2, Mal = 3, geteilt = 4, wurzel ziehen = 5, Potzen = 6"); System.out.println("Bitte geben Operator ein: "); Scanner sc = new Scanner(System.in); a = sc.nextInt(); System.out.println("Bitte die erste Variabel ein: "); x = sc.nextDouble(); System.out.println("Bitte die zweite Variabel und als Würzel ein: "); y = sc.nextDouble(); String myString = "a"; char [] myCharArray = myString.toCharArray (); switch(a) { case '1': System.out.println( x + y ); break; case '2': System.out.println( x - y ); break; case '3': System.out.println( x * y ); break; case '4': System.out.println( x / y ); break; } } } -------------------- |
|
|
![]() ![]() |
Vereinfachte Darstellung | Aktuelles Datum: 06.07.2025, 16:15 |