Skip to content

Instantly share code, notes, and snippets.

@lnsp
Created October 23, 2016 11:01
Show Gist options
  • Save lnsp/22c932c783cf203e679cc0bde374a276 to your computer and use it in GitHub Desktop.
Save lnsp/22c932c783cf203e679cc0bde374a276 to your computer and use it in GitHub Desktop.
Lösung zur Übung
import java.util.Scanner;
public class JavaKurs6 {
public static void main(String[] args) {
// Nicht ändern!!
Scanner in = new Scanner(System.in);
System.out.print("Bitte gib eine Zahl ein: ");
int a = in.nextInt(), b = 0, c = 0, d = 0;
// Hier beginnt dein Code!
// Aufgabe 1: Das 3-fache von a ausgeben und in b abspeichern
b = 3 * a;
// Aufgabe 2: Den Rest von a / 3 berechnen und in c abspeichern
c = a % 3;
// Aufgabe 3: Die Summe von b und c in d abspeichern
d = b + c;
// Nicht mehr ändern!!!
System.out.println("b = " + b);
System.out.println("c = " + c);
System.out.println("d = " + d);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment