-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAMethode2.java
More file actions
31 lines (28 loc) · 1.05 KB
/
AMethode2.java
File metadata and controls
31 lines (28 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/*Schreibt eine Methode, die 2 Zahlen entgegennimmt, diese multipliziert und das Ergebnis ausgibt ,
wer möchte gerne mit User Input über Konsole
Ergebniss: Eingabe über andere Methode - Lösung mit Array */
import java.util.Scanner;
public class AMethode2 {
public static void main(String[] args) {
int[] werte = eingaben();
int x= werte[0];
int y= werte[1];
int summe = multiplizieren(x,y);
// int produkt = multiplizieren(2,5);
System.out.println("Das Produkt von "+x+" und "+y+" ist: "+summe);
// System.out.println("Das Produkt von 2 und 5 ist: "+produkt);
}
public static int[] eingaben(){
Scanner eingabe = new Scanner(System.in);
System.out.println("Gib eine Zahl ein: ");
int xx = eingabe.nextInt();
System.out.println("Gib eine andere Zahl ein: ");
int yy= eingabe.nextInt();
int[] ergebnis ={xx,yy};
eingabe.close();
return(ergebnis);
}
public static int multiplizieren(int a, int b){
return a*b;
}
}