Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Programm {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- Scanner rechenart = new Scanner(System.in);
- double zahl1, zahl2;
- int eingabe;
- String frage = "f";
- while(frage.equals("f")) {
- System.out.println("Was wollen Sie tun?\n1.) Addieren \n2.) Subtrahieren \n3.) Dividieren"
- + "\n4.) Multiplizieren");
- eingabe = rechenart.nextInt();
- System.out.println("Geben Sie die Erste Zahl ein!");
- zahl1 = rechenart.nextDouble();
- System.out.println("Geben Sie die zweite Zahl ein!");
- zahl2 = rechenart.nextDouble();
- switch(eingabe) {
- case 1:
- System.out.println(Adieren(zahl1,zahl2));
- break;
- case 2:
- System.out.println(Subtrahieren(zahl1,zahl2));
- break;
- case 3:
- System.out.println(Dividieren(zahl1,zahl2));
- break;
- case 4:
- System.out.println(multiplizieren(zahl1,zahl2));
- break;
- }
- }
- rechenart.close();
- }
- public static double Adieren(double zahl1, double zahl2) {
- return zahl1 + zahl2;
- }
- public static double Subtrahieren(double zahl1, double zahl2) {
- return zahl1 - zahl2;
- }
- public static double Dividieren(double zahl1, double zahl2) {
- return zahl1 / zahl2;
- }
- public static double multiplizieren(double zahl1, double zahl2) {
- return zahl1 * zahl2;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement