Java

835 views

Published on

Published in: Technology, News & Politics
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
835
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
29
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Java

  1. 1. Array Import java.io.*; public class status { public static void main(String argv[]) throws IOException { int i, anzahl, auswahl; String status[], str; BufferedReader input = new BufferedReader(new InputStreamReader(System.in)); System.out.print(quot;Geben Sie die Anzahl der Stati ein: quot;); str=input.readLine(); anzahl=Integer.parseInt(str); status= new String[anzahl]; for(i=0;i<anzahl;i++) { System.out.print(quot;Geben Sie den Status ein: quot;); System.out.println(); status[i]=input.readLine(); } System.out.println(quot; Nr Statusquot;); for(i=0;i<anzahl;i++) { System.out.println(quot; quot;+(i+1)+quot; quot;+status[i]); } System.out.print(quot;Welchen Status wollen Sie sehen? quot;); str=input.readLine(); auswahl=Integer.parseInt(str); System.out.println(status[auswahl-1]); } }
  2. 2. Klassen import java.io.*; public class Main { public static void main(String argv[]) { Quader quader1; quader1=new Quader(); quader1.breite=10; quader1.hoehe=20; quader1.laenge=30; quader1.showVolumen(); quader1.showOberflaeche(); } } public class Quader { //Attribute public int laenge; public int breite; public int hoehe; //Methoden public void showVolumen() { int volumen; volumen=breite*hoehe*laenge; System.out.println(quot; Das Volumen betraegt: quot;+ volumen + quot;m*m*mquot;); } public void showOberflaeche() { int oberflaeche; oberflaeche=2*(breite*laenge)+(breite*hoehe)+(laenge*hoehe); System.out.println(quot; Die Oberflaeche betraegt: quot;+ oberflaeche+ quot;m*m*mquot;); } }

×