Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Taschenrechner {
- String inputString = "";
- int inputInteger = 0;
- public static final int Addition = 1;
- public static final int Subtraktion = 2;
- public static final int Multiplikation = 3;
- public static final int Division = 4;
- public static final int Prozent = 5;
- public void startEingabe(){
- System.out.println("Bitte geben Sie einen ganzzahligen Wert ein:");
- Scanner sc = new Scanner(System.in);
- inputString = sc.next();
- inputInteger = Integer.parseInt(inputString);
- }
- public void startEingabe2(){
- System.out.println("Bitte geben Sie einen weiteren ganzzahligen Wert ein:");
- Scanner sc = new Scanner(System.in);
- inputString = sc.next();
- inputInteger = Integer.parseInt(inputString);
- }
- public void startOperation(){
- System.out.println("Bitte geben Sie die gewuenschte Operation ein:");
- Scanner sc = new Scanner(System.in);
- inputString = sc.next();
- inputInteger = Integer.parseInt(inputString);
- }
- public static void main(String[] args){
- Taschenrechner taschenrechner = new Taschenrechner();
- taschenrechner.startEingabe();
- taschenrechner.startEingabe2();
- taschenrechner.startOperation();
- double z1, z2;
- double ausgabe;
- switch (operation){
- case Addition: ausgabe = z1 + z2;
- System.out.println("Das Ergebnis lautet: " + ausgabe);
- break;
- case Subtraktion: ausgabe = z1 - z2;
- System.out.println("Das Ergebnis lautet: " + ausgabe);
- break;
- case Multiplikation: ausgabe = z1 * z2;
- System.out.println("Das Ergebnis lautet: " + ausgabe);
- break;
- case Division: ausgabe = z1 % z2;
- System.out.println("Das Ergebnis lautet: " + ausgabe);
- break;
- default:
- System.out.println("Eingabe ungueltig");
- break;
- }
- }
- }
Add Comment
Please, Sign In to add comment