Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Java
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. 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;);
}
}