+Alles zusammen
parent
d6c664f0e7
commit
76fcedd923
Binary file not shown.
@ -1,61 +0,0 @@
|
||||
package com.company;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class EinkaufswagenNummer {
|
||||
|
||||
public static void main(String[] args) {
|
||||
Eingabe();
|
||||
}
|
||||
|
||||
public static void Eingabe(){
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
|
||||
System.out.println("Bitte geben sie die Kennnummer ein: ");
|
||||
String wagenNummer = scanner.nextLine().replace("-", "");
|
||||
|
||||
while (wagenNummer.length() != 16) {
|
||||
System.out.println("Die Nummer muss 16 Stellen lang sein. Bitte erneut eingeben");
|
||||
wagenNummer = scanner.nextLine().replace("-", "");
|
||||
}
|
||||
|
||||
boolean korrektheit = pruefungNummer(wagenNummer);
|
||||
ausgabe(korrektheit);
|
||||
}
|
||||
|
||||
public static boolean pruefungNummer(String nummer){
|
||||
String gewichtung = "";
|
||||
for (int i = 0; i < nummer.length() - 1; i++) {
|
||||
char stelle = nummer.charAt(i);
|
||||
gewichtung += Character.getNumericValue(stelle) * (i % 2 == 0 ? 1 : 1);
|
||||
}
|
||||
|
||||
int PruefziffEntfernen = nummer.charAt(nummer.length() - 1);
|
||||
|
||||
int pruefziffer = Character.getNumericValue(PruefziffEntfernen);
|
||||
int PruefzifferBerechnet = 10 - gewichtung % 10;
|
||||
|
||||
boolean korrektheit = false;
|
||||
if (PruefzifferBerechnet != pruefziffer){
|
||||
korrektheit = false;
|
||||
} else {
|
||||
korrektheit = true;
|
||||
}
|
||||
|
||||
return(korrektheit);
|
||||
}
|
||||
|
||||
public static void ausgabe(boolean korrektheit){
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
if (korrektheit != true) {
|
||||
System.out.println("Die Kennnummer ist nicht korrekt oder ungültig!");
|
||||
|
||||
} else {
|
||||
System.out.println("Kennnummer is gültig!");
|
||||
}
|
||||
System.out.println("Wollen Sie eine weitere Nummer pruefen? Wenn ja bitte mit Y bestätigen. Wenn nich kann das Programm mit N beendet werden.");
|
||||
String weiter = scanner.nextLine().replace("-", "");
|
||||
if(weiter.equals("Y")) {
|
||||
Eingabe();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package com.company;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
public class Fernbedinung {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
senderAuswahl sA = new senderAuswahl();
|
||||
int senderPosition = 0;
|
||||
int unednlich = 0;
|
||||
|
||||
|
||||
|
||||
System.out.println("Wählen sie bitte eine der folgende Aktionen aus: ");
|
||||
System.out.println("up = Program hoch schalten ");
|
||||
System.out.println("down = Program runter schalten ");
|
||||
System.out.println("rename = Programname einspeichern oder Umbennenen ");
|
||||
System.out.println("name = Programm name ausgeben ");
|
||||
System.out.println("x = Programm beenden");
|
||||
|
||||
while(unednlich != 1) {
|
||||
|
||||
String programmAuswahl = scanner.nextLine().replace("-", "");
|
||||
|
||||
if (programmAuswahl.equals("up")) {
|
||||
senderPosition = sA.senderWechsel("UP", senderPosition);
|
||||
System.out.println(senderPosition);
|
||||
}
|
||||
if (programmAuswahl.equals("down")) {
|
||||
senderPosition = sA.senderWechsel("DOWN", senderPosition);
|
||||
System.out.println(senderPosition);
|
||||
}
|
||||
if (programmAuswahl.equals("rename")) {
|
||||
System.out.println("Welcher Name soll der Sender haben? ");
|
||||
String neuerSenderName = scanner.nextLine().replace("-", "");
|
||||
sA.nameSpeichern(senderPosition, neuerSenderName);
|
||||
System.out.println("Neur Name lautet: "+neuerSenderName);
|
||||
}
|
||||
if (programmAuswahl.equals("name")) {
|
||||
System.out.println(sA.nameAusgeben(senderPosition));
|
||||
}
|
||||
if (programmAuswahl.equals("x")) {
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package com.company;
|
||||
|
||||
public class HealthKlasse {
|
||||
|
||||
|
||||
public double bmiRechner(double gewicht, double große){
|
||||
|
||||
return (gewicht / Math.pow(große, 2));
|
||||
|
||||
}
|
||||
|
||||
public String kategorie(double BMI){
|
||||
|
||||
String klasse = "";
|
||||
|
||||
if(BMI < 18.5){
|
||||
klasse = "untergewichtig";
|
||||
}
|
||||
else if(BMI <= 25){
|
||||
klasse = "normalgewichtig";
|
||||
}
|
||||
else if(BMI <= 30){
|
||||
klasse = "übergewichtig";
|
||||
}
|
||||
else{
|
||||
klasse = "fettleibig";
|
||||
}
|
||||
|
||||
return klasse;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package com.company;
|
||||
|
||||
public class StepCounter {
|
||||
|
||||
public String date;
|
||||
public int schritte = 0;
|
||||
|
||||
|
||||
public StepCounter(String date){
|
||||
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
public void incrementSteps(){
|
||||
|
||||
this.schritte++;
|
||||
}
|
||||
|
||||
public void incrementManySteps(int steps){
|
||||
|
||||
this.schritte += steps;
|
||||
}
|
||||
|
||||
public String toString(){
|
||||
|
||||
return "Am "+this.date+" bin ich "+this.schritte+" Schritte gelaufen";
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package com.company;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
public class bmiEingabe {
|
||||
|
||||
|
||||
public static void main(String[] args){
|
||||
|
||||
Scanner scanner = new Scanner(System.in);
|
||||
|
||||
System.out.println("Bitte geben sie Ihr Gewicht ein: ");
|
||||
String gewicht = scanner.nextLine().replace("-", "");
|
||||
System.out.println("Bitte geben sie Ihre Größe ein: ");
|
||||
String große = scanner.nextLine().replace("-", "");
|
||||
|
||||
double dGewicht = Double.parseDouble(gewicht);
|
||||
double dGroße = Double.parseDouble(große);
|
||||
|
||||
HealthKlasse HK = new HealthKlasse();
|
||||
|
||||
double BMI = HK.bmiRechner(dGewicht, dGroße);
|
||||
|
||||
ausgabe(BMI);
|
||||
}
|
||||
|
||||
public static void ausgabe(double BMI){
|
||||
|
||||
HealthKlasse HK = new HealthKlasse();
|
||||
String klasse = "";
|
||||
|
||||
klasse = HK.kategorie(BMI);
|
||||
|
||||
System.out.println("Mit einem BMI von "+BMI+" sind Sie "+klasse+".");
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package com.company;
|
||||
|
||||
public class schrittzähler {
|
||||
|
||||
public static void main(String[] args){
|
||||
|
||||
StepCounter sc = new StepCounter("23.11.2020");
|
||||
sc.incrementSteps();
|
||||
sc.incrementSteps();
|
||||
System.out.println(sc.toString());
|
||||
|
||||
sc.incrementManySteps(10);
|
||||
System.out.println(sc.toString());
|
||||
|
||||
sc.incrementManySteps(-10);
|
||||
System.out.println(sc.toString());
|
||||
|
||||
sc.incrementManySteps(101010);
|
||||
System.out.println(sc.toString());
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package com.company;
|
||||
|
||||
public class senderAuswahl {
|
||||
|
||||
private String[] senderNamen = new String[30];
|
||||
|
||||
public int senderWechsel(String richtung, int senderPosition){
|
||||
|
||||
if(richtung.equals("UP")){
|
||||
if(senderPosition >= 30){
|
||||
senderPosition = -1;
|
||||
}
|
||||
senderPosition = senderPosition+1;
|
||||
}
|
||||
if(richtung.equals("DOWN")){
|
||||
if(senderPosition <= 0){
|
||||
senderPosition = 31;
|
||||
}
|
||||
senderPosition = senderPosition-1;
|
||||
}
|
||||
return senderPosition;
|
||||
}
|
||||
|
||||
public void nameSpeichern(int senderPosition, String neuerSenderName){
|
||||
senderNamen[senderPosition] = neuerSenderName;
|
||||
}
|
||||
|
||||
public String nameAusgeben(int senderPosition){
|
||||
String aktuellerSendeName = senderNamen[senderPosition];
|
||||
return aktuellerSendeName;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue