Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Tannenbaum {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- System.out.println("Bitte geben Sie die hoehe ein :)");
- int hoehe = scanner.nextInt();
- for(int i=0;i<hoehe; i++) // Eingabe z.b 5 also 5 durchgänge da die bedingung nicht mehr vorhanden ist.
- {
- for(int j=0;j<hoehe -1 -i ; j++) // Puffer erstellen deshalb im String kein wert drine
- {
- System.out.print(" ");
- }
- for(int k=0; k<i*2+1;k++) // Blätter deshalb * im String
- {
- System.out.print("*");
- }
- System.out.println(""); // Naechste Zeilenumbruch
- }
- for (int i=1; i<hoehe; i++)
- System.out.print(" ");
- System.out.println("I");
- scanner.close();
- }
- }
- -------------------------------------------------------------------
- public class testat {
- public static void main(String[] args) {
- int zahl = 2;
- int zahl2 = 0;
- for(int i=2;i<32; i++)
- {
- zahl = zahl * 2;
- }
- zahl2= zahl -1;
- System.out.println("Die kleinste Zahl ist "+ zahl + " Der höcshte ist "+ zahl2);
- }
- }
- ----------------------------------------------------------------------------
- import java.util.Scanner;
- public class testat2 {
- public static void main(String[] args)
- {
- Scanner eingabe = new Scanner(System.in);
- String bier = "bier";
- int test = 0;
- String s ="";
- System.out.println("Bitte geben sie ein String ein");
- String eingabe_vom_benutzer = eingabe.next();
- int counter =0;
- while(eingabe_vom_benutzer.contains(bier))
- {
- counter++;
- test = eingabe_vom_benutzer.indexOf(bier);
- s = eingabe_vom_benutzer.substring(test+1);
- eingabe_vom_benutzer = s;
- }
- eingabe.close();
- System.out.println(counter);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement