Compare commits
6 Commits
90a323ce01
...
master
Author | SHA1 | Date | |
---|---|---|---|
d8bd33e6d1 | |||
3c28114bd5 | |||
![]() |
998d8aefd7 | ||
![]() |
f85e17a726 | ||
3f42a3aca5 | |||
![]() |
e1a7f69bc7 |
13
README.md
Normal file
13
README.md
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
# G91_Einkommen
|
||||||
|
Entwickeln Sie ein Java Programm zur Anzeige des gebietsabhängigen Durchschnittseinkommens von Bundesbürgern auf der Konsole.
|
||||||
|
|
||||||
|
## Beteiligte
|
||||||
|
- Jan-Philipp Schulte
|
||||||
|
- Malte Schulze Hobeling
|
||||||
|
- Reshad Meher
|
||||||
|
- Richard Reiswich
|
||||||
|
- Johannes Kantz
|
||||||
|
|
||||||
|
|
||||||
|
[GitTea Repo](https://git.bib.de/Homeoffice/passivesEinkommen)
|
||||||
|
|
@@ -7,23 +7,29 @@ public class EinkommenInfo {
|
|||||||
GebietsDatei datei = new GebietsDatei("Einkommen.csv");
|
GebietsDatei datei = new GebietsDatei("Einkommen.csv");
|
||||||
List<Gebiet> gebiet = datei.getGebiete();
|
List<Gebiet> gebiet = datei.getGebiete();
|
||||||
GebietsListe gebietsListe = new GebietsListe(gebiet);
|
GebietsListe gebietsListe = new GebietsListe(gebiet);
|
||||||
System.out.println(gebiet.size() + " Gebiete wurden eingelesen.");
|
|
||||||
System.out.println(gebietsListe.getAnzahlUnvollstaendig() + " davon haben unvollständige Angaben.");
|
System.out.println(gebietsListe.getAnzahlGesamt() + " Gebiete wurden eingelesen.");
|
||||||
System.out.println();
|
System.out.println(gebietsListe.getAnzahlUnvollständig() + " davon haben unvollständige Angaben.\n");
|
||||||
|
|
||||||
System.out.println("Gebiet mit dem geringsten Durchschnittseinkommen:");
|
System.out.println("Gebiet mit dem geringsten Durchschnittseinkommen:");
|
||||||
System.out.println(gebietsListe.getGebietMinDurchschnittEinkommen());
|
System.out.println(gebietsListe.getGebietMinDurchschnittsEinkommen());
|
||||||
|
|
||||||
|
System.out.println("Gebiet mit der größten Einwohernzahl:");
|
||||||
|
System.out.println(gebietsListe.getGebietMaxAnzahlEinwohner());
|
||||||
|
|
||||||
Scanner sc = new Scanner(System.in);
|
Scanner sc = new Scanner(System.in);
|
||||||
while(true){
|
while (true) {
|
||||||
System.out.print("Name des Gebietes: ");
|
System.out.print("Name des Gebietes: ");
|
||||||
String input = sc.nextLine();
|
String input = sc.nextLine();
|
||||||
if(input.isEmpty()){
|
if (input.isEmpty()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
List<Gebiet> foundAreas = gebietsListe.getGebietNachNamen(input);
|
List<Gebiet> foundAreas = gebietsListe.getGebieteNachNamen(input);
|
||||||
for (Gebiet area : foundAreas) {
|
for (Gebiet area : foundAreas) {
|
||||||
System.out.println(area);
|
System.out.println(area);
|
||||||
}
|
}
|
||||||
System.out.println(foundAreas.size() + " Gebiete wurden gefunden.");
|
System.out.println(foundAreas.size() + " Gebiete wurden gefunden.\n");
|
||||||
}
|
}
|
||||||
|
sc.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
5
src/GebiesDateiInterface.java
Normal file
5
src/GebiesDateiInterface.java
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public interface GebiesDateiInterface {
|
||||||
|
ArrayList<Gebiet> getGebiete();
|
||||||
|
}
|
@@ -1,4 +1,4 @@
|
|||||||
public class Gebiet implements GebietInterface{
|
public class Gebiet implements GebietInterface {
|
||||||
private int jahr;
|
private int jahr;
|
||||||
private int schlüssel;
|
private int schlüssel;
|
||||||
private String name;
|
private String name;
|
||||||
@@ -30,7 +30,7 @@ public class Gebiet implements GebietInterface{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getGesamtEinkommen() {
|
public long getGesamtEinkommen() {
|
||||||
if(gesamtEinkommen <= 0){
|
if (gesamtEinkommen <= 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return gesamtEinkommen;
|
return gesamtEinkommen;
|
||||||
@@ -38,7 +38,7 @@ public class Gebiet implements GebietInterface{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getDurchschnittsEinkommen() {
|
public int getDurchschnittsEinkommen() {
|
||||||
if(durchschnittsEinkommen <= 0){
|
if (durchschnittsEinkommen <= 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return durchschnittsEinkommen;
|
return durchschnittsEinkommen;
|
||||||
@@ -46,11 +46,15 @@ public class Gebiet implements GebietInterface{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getAnzahlEinwohner() {
|
public int getAnzahlEinwohner() {
|
||||||
return (int)(gesamtEinkommen / durchschnittsEinkommen);
|
return (int) (gesamtEinkommen * 1000 / durchschnittsEinkommen);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return getName() + "\n" + getAnzahlEinwohner() + " Einwohner\n" + getDurchschnittsEinkommen() + " Euro / Einwohner\n";
|
if (getDurchschnittsEinkommen() <= 1 || getGesamtEinkommen() <= 1) {
|
||||||
|
return getName() + "\n" + "Einwohnerzahl unbekannt\n" + "Durchschnittseinkommen unbekannt\n";
|
||||||
|
}
|
||||||
|
return getName() + "\n" + getAnzahlEinwohner() + " Einwohner\n" + getDurchschnittsEinkommen()
|
||||||
|
+ " Euro / Einwohner\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -2,7 +2,7 @@ import java.nio.file.Files;
|
|||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class GebietsDatei {
|
public class GebietsDatei implements GebiesDateiInterface {
|
||||||
|
|
||||||
private String dateiName;
|
private String dateiName;
|
||||||
|
|
||||||
@@ -15,7 +15,9 @@ public class GebietsDatei {
|
|||||||
try {
|
try {
|
||||||
Files.readAllLines(Paths.get(dateiName)).forEach(line -> {
|
Files.readAllLines(Paths.get(dateiName)).forEach(line -> {
|
||||||
String[] parts = line.split(";");
|
String[] parts = line.split(";");
|
||||||
gebiete.add(new Gebiet(Integer.parseInt(parts[0]), Integer.parseInt(parts[1]), parts[2], (parts[3].equals("-")) ? 0 : Long.parseLong(parts[3]), (parts[4].equals("-")) ? 0 : Integer.parseInt(parts[4])));
|
gebiete.add(new Gebiet(Integer.parseInt(parts[0]), Integer.parseInt(parts[1]), parts[2],
|
||||||
|
(parts[3].equals("-")) ? -1 : Long.parseLong(parts[3]),
|
||||||
|
(parts[4].equals("-")) ? -1 : Integer.parseInt(parts[4])));
|
||||||
});
|
});
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@@ -1,34 +1,40 @@
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class GebietsListe {
|
public class GebietsListe implements GebietsListeInterface{
|
||||||
private List<GebietMock> gebietListe = new ArrayList<>();
|
private List<Gebiet> gebiete = new ArrayList<>();
|
||||||
|
|
||||||
public GebietsListe(List<Gebiet> gebiete){
|
public GebietsListe(List<Gebiet> gebiete) {
|
||||||
this.gebietListe = gebietListe;
|
this.gebiete = gebiete;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Gebiet getGebietMinDurchschnittEinkommen(){
|
public Gebiet getGebietMinDurchschnittsEinkommen() {
|
||||||
|
return gebiete.stream()
|
||||||
return null;
|
.filter(g -> g.getDurchschnittsEinkommen() != -1)
|
||||||
|
.min((g1, g2) -> g1.getDurchschnittsEinkommen() - g2.getDurchschnittsEinkommen())
|
||||||
|
.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Gebiet getGebietMaxEinwohner(){
|
public Gebiet getGebietMaxAnzahlEinwohner() {
|
||||||
|
return gebiete.stream()
|
||||||
return null;
|
.filter(g -> g.getDurchschnittsEinkommen() != -1)
|
||||||
|
.max((g1, g2) -> g1.getAnzahlEinwohner() - g2.getAnzahlEinwohner())
|
||||||
|
.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getAnzahlGesamt(){
|
public int getAnzahlGesamt() {
|
||||||
return 0;
|
return gebiete.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getAnzahlUnvollstaendig(){
|
public int getAnzahlUnvollständig() {
|
||||||
|
return (int) gebiete.stream()
|
||||||
return 0;
|
.filter(g -> g.getDurchschnittsEinkommen() == -1 || g.getGesamtEinkommen() == -1)
|
||||||
|
.count();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Gebiet> getGebietNachNamen(String namensanfang){
|
public List<Gebiet> getGebieteNachNamen(String namensanfang) {
|
||||||
|
return gebiete.stream()
|
||||||
return null;
|
.filter(g -> g.getName().startsWith(namensanfang))
|
||||||
|
.toList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
9
src/GebietsListeInterface.java
Normal file
9
src/GebietsListeInterface.java
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface GebietsListeInterface {
|
||||||
|
Gebiet getGebietMinDurchschnittsEinkommen();
|
||||||
|
Gebiet getGebietMaxAnzahlEinwohner();
|
||||||
|
int getAnzahlGesamt();
|
||||||
|
int getAnzahlUnvollständig();
|
||||||
|
List<Gebiet> getGebieteNachNamen(String namensanfang);
|
||||||
|
}
|
Reference in New Issue
Block a user