You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

99 lines
1.5 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. package programmiermethoden_und_Werkzeuge;
  2. import java.util.Scanner;
  3. public class Taschenrechner {
  4. int addition(int a, int b) {
  5. return a + b;
  6. }
  7. int multiplikation(int a, int b) {
  8. return a * b;
  9. }
  10. int division(int a, int b) {
  11. return a / b;
  12. }
  13. int potenzieren(int a, int b) {
  14. int temp = 1;
  15. if(b == 0) {
  16. return 1;
  17. }
  18. for(int i = 0; i < b; i++) {
  19. temp = temp * a;
  20. }
  21. return temp;
  22. }
  23. boolean kleinerAls(int a, int b) {
  24. return a < b;
  25. }
  26. boolean groeßerAls(int a, int b) {
  27. return a > b;
  28. }
  29. boolean gleich(int a, int b) {
  30. return a == b;
  31. }
  32. int randomNummer(int a, int b) {
  33. //Zufällige Nummer von a bis b
  34. int temp = 0;
  35. temp = (int) (Math.random() * (b + 1) ) + a;
  36. return temp;
  37. }
  38. double pie() {
  39. return Math.PI;
  40. }
  41. static int eingabe() {
  42. Scanner scan = new Scanner(System.in);
  43. int intScan= scan.nextInt();
  44. scan.close();
  45. return intScan;
  46. }
  47. void startTaschenrechner() {
  48. //Funktion zum Starten des Taschenrechnerprogramms
  49. System.out.println("1.Addition, 2.Multiplikation, 3.Division, 4.Potenzieren, 5.kleinerAls, 6.groeßerAls, 7.Gleichgroß, 8.Zufällige Zahl, 9.PI");
  50. Scanner scan = new Scanner(System.in);
  51. int s = scan.nextInt();
  52. scan.close();
  53. switch (s) {
  54. case 1: {
  55. System.out.println("Addition\n");
  56. System.out.println("Ergebnis:" + addition(eingabe(), eingabe()));
  57. break;
  58. }
  59. case 2: {
  60. division(eingabe(), eingabe());
  61. break;
  62. }
  63. default:
  64. throw new IllegalArgumentException("Unexpected value: " + s);
  65. }
  66. }
  67. }