Advertisement
Zidinjo

Alle 3 Testate

Nov 10th, 2014
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.80 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class Tannenbaum {
  3.  
  4.     public static void main(String[] args) {
  5.        
  6.         Scanner scanner = new Scanner(System.in);
  7.        
  8.         System.out.println("Bitte geben Sie die hoehe ein :)");
  9.        
  10.         int hoehe = scanner.nextInt();
  11.                
  12.         for(int i=0;i<hoehe; i++) // Eingabe z.b 5 also 5 durchgänge da die bedingung nicht mehr vorhanden ist.
  13.         {
  14.             for(int j=0;j<hoehe -1 -i ; j++) // Puffer erstellen deshalb im String kein wert drine
  15.             {
  16.                 System.out.print(" ");
  17.             }
  18.            
  19.             for(int k=0; k<i*2+1;k++) // Blätter deshalb * im String
  20.             {
  21.                 System.out.print("*");
  22.             }
  23.            
  24.             System.out.println(""); // Naechste Zeilenumbruch
  25.         }
  26.         for (int i=1; i<hoehe; i++)
  27.             System.out.print(" ");
  28.             System.out.println("I");
  29.         scanner.close();
  30.     }
  31. }
  32.  
  33. -------------------------------------------------------------------
  34.  
  35. public class testat {
  36.  
  37.     public static void main(String[] args) {
  38.        
  39.         int zahl = 2;
  40.         int zahl2 = 0;
  41.        
  42.         for(int i=2;i<32; i++)
  43.         {
  44.             zahl = zahl * 2;
  45.         }
  46.        
  47.         zahl2= zahl -1;
  48.         System.out.println("Die kleinste Zahl ist  "+ zahl + " Der höcshte ist "+ zahl2);
  49.     }
  50. }
  51.  
  52. ----------------------------------------------------------------------------
  53. import java.util.Scanner;
  54. public class testat2 {
  55.    
  56.    
  57.     public static void main(String[] args)
  58.     {
  59.         Scanner eingabe = new Scanner(System.in);
  60.        
  61.         String bier = "bier";
  62.         int test = 0;
  63.         String s ="";
  64.         System.out.println("Bitte geben sie ein String ein");
  65.        
  66.         String eingabe_vom_benutzer = eingabe.next();
  67.         int counter =0;
  68.         while(eingabe_vom_benutzer.contains(bier))
  69.         {
  70.             counter++;
  71.             test = eingabe_vom_benutzer.indexOf(bier);
  72.             s = eingabe_vom_benutzer.substring(test+1);
  73.             eingabe_vom_benutzer = s;
  74.         }
  75.         eingabe.close();
  76.         System.out.println(counter);
  77.     }
  78.  
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement