Guest User

Untitled

a guest
Jun 18th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3.  
  4. public class Taschenrechner {
  5.  
  6. String inputString = "";
  7. int inputInteger = 0;
  8.  
  9. public static final int Addition = 1;
  10. public static final int Subtraktion = 2;
  11. public static final int Multiplikation = 3;
  12. public static final int Division = 4;
  13. public static final int Prozent = 5;
  14.  
  15.  
  16. public void startEingabe(){
  17. System.out.println("Bitte geben Sie einen ganzzahligen Wert ein:");
  18. Scanner sc = new Scanner(System.in);
  19. inputString = sc.next();
  20. inputInteger = Integer.parseInt(inputString);
  21. }
  22.  
  23. public void startEingabe2(){
  24. System.out.println("Bitte geben Sie einen weiteren ganzzahligen Wert ein:");
  25. Scanner sc = new Scanner(System.in);
  26. inputString = sc.next();
  27. inputInteger = Integer.parseInt(inputString);
  28. }
  29.  
  30. public void startOperation(){
  31. System.out.println("Bitte geben Sie die gewuenschte Operation ein:");
  32. Scanner sc = new Scanner(System.in);
  33. inputString = sc.next();
  34. inputInteger = Integer.parseInt(inputString);
  35. }
  36.  
  37.  
  38. public static void main(String[] args){
  39. Taschenrechner taschenrechner = new Taschenrechner();
  40. taschenrechner.startEingabe();
  41. taschenrechner.startEingabe2();
  42. taschenrechner.startOperation();
  43.  
  44. double z1, z2;
  45. double ausgabe;
  46.  
  47. switch (operation){
  48. case Addition: ausgabe = z1 + z2;
  49. System.out.println("Das Ergebnis lautet: " + ausgabe);
  50. break;
  51. case Subtraktion: ausgabe = z1 - z2;
  52. System.out.println("Das Ergebnis lautet: " + ausgabe);
  53. break;
  54. case Multiplikation: ausgabe = z1 * z2;
  55. System.out.println("Das Ergebnis lautet: " + ausgabe);
  56. break;
  57. case Division: ausgabe = z1 % z2;
  58. System.out.println("Das Ergebnis lautet: " + ausgabe);
  59. break;
  60. default:
  61. System.out.println("Eingabe ungueltig");
  62. break;
  63. }
  64.  
  65. }
  66. }
Add Comment
Please, Sign In to add comment