Advertisement
Guest User

Taschenrechner_Simon_Köck

a guest
Mar 29th, 2020
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1.  
  2. import java.util.Scanner;
  3. public class Programm {
  4.  
  5.  
  6. public static void main(String[] args) {
  7. // TODO Auto-generated method stub
  8.  
  9.  
  10. Scanner rechenart = new Scanner(System.in);
  11. double zahl1, zahl2;
  12. int eingabe;
  13. String frage = "f";
  14.  
  15.  
  16. while(frage.equals("f")) {
  17.  
  18. System.out.println("Was wollen Sie tun?\n1.) Addieren \n2.) Subtrahieren \n3.) Dividieren"
  19. + "\n4.) Multiplizieren");
  20. eingabe = rechenart.nextInt();
  21.  
  22. System.out.println("Geben Sie die Erste Zahl ein!");
  23. zahl1 = rechenart.nextDouble();
  24. System.out.println("Geben Sie die zweite Zahl ein!");
  25. zahl2 = rechenart.nextDouble();
  26.  
  27.  
  28.  
  29. switch(eingabe) {
  30.  
  31. case 1:
  32. System.out.println(Adieren(zahl1,zahl2));
  33. break;
  34. case 2:
  35. System.out.println(Subtrahieren(zahl1,zahl2));
  36. break;
  37. case 3:
  38. System.out.println(Dividieren(zahl1,zahl2));
  39.  
  40. break;
  41. case 4:
  42. System.out.println(multiplizieren(zahl1,zahl2));
  43. break;
  44.  
  45. }
  46. }
  47. rechenart.close();
  48. }
  49. public static double Adieren(double zahl1, double zahl2) {
  50. return zahl1 + zahl2;
  51. }
  52. public static double Subtrahieren(double zahl1, double zahl2) {
  53. return zahl1 - zahl2;
  54. }
  55. public static double Dividieren(double zahl1, double zahl2) {
  56. return zahl1 / zahl2;
  57. }
  58. public static double multiplizieren(double zahl1, double zahl2) {
  59. return zahl1 * zahl2;
  60. }
  61.  
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement