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.

92 lines
1.3 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
  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. void eingabe() {
  42. }
  43. void startTaschenrechner() {
  44. //Funktion zum Starten des Taschenrechnerprogramms
  45. System.out.println("1.Addition, 2.Multiplikation, 3.Division, 4.Potenzieren, 5.kleinerAls, 6.groeßerAls, 7.Gleichgroß, 8.Zufällige Zahl, 9.PI");
  46. Scanner scan = new Scanner(System.in);
  47. int s = scan.nextInt();
  48. scan.close();
  49. switch (s) {
  50. case 1: {
  51. addition(s, s);
  52. break;
  53. }
  54. case 2: {
  55. division(s, s);
  56. break;
  57. }
  58. default:
  59. throw new IllegalArgumentException("Unexpected value: " + s);
  60. }
  61. }
  62. }