Compare commits
29 Commits
8c6c81e200
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| d8bd33e6d1 | |||
| 3c28114bd5 | |||
|
|
998d8aefd7 | ||
|
|
f85e17a726 | ||
| 3f42a3aca5 | |||
|
|
e1a7f69bc7 | ||
| 90a323ce01 | |||
| 0643732d08 | |||
| 7ca888121d | |||
| da5bcc93bf | |||
|
|
81b4cbeb7e | ||
|
|
aab1fe68d7 | ||
|
|
8382a47d7e | ||
| daf0ec541d | |||
| 268f4eee43 | |||
| a2bd838467 | |||
| 78dfa848fa | |||
|
|
2562126caa | ||
| 9c6592fbff | |||
|
|
a1827ac6a4 | ||
| f9bc2db7bb | |||
| 044d274da5 | |||
| 6fb0c50f62 | |||
| 8fd4bc6d32 | |||
| 57d88900ce | |||
| 266c4b2b4d | |||
| 9c14f86b00 | |||
| f5ebd6469b | |||
| 1f53698bc7 |
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -1,5 +1,3 @@
|
||||
Jahr;Schlüssel;Region;verfügbares Einkommen der privaten Haushalte;verfüg. Einkommen der priv. Haushalte je Einwohner
|
||||
;;;Tsd. EUR;EUR
|
||||
2016;01001;Flensburg, Kreisfreie Stadt;1602046;18481
|
||||
2016;01002;Kiel, Landeshauptstadt, Kreisfreie Stadt;4643584;18810
|
||||
2016;01003;Lübeck, Hansestadt, Kreisfreie Stadt;4237638;19575
|
||||
|
||||
|
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)
|
||||
|
||||
35
src/EinkommenInfo.java
Normal file
35
src/EinkommenInfo.java
Normal file
@@ -0,0 +1,35 @@
|
||||
import java.util.List;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class EinkommenInfo {
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Übersicht über Bevölkerungszahl und Einkommen in Deutschland");
|
||||
GebietsDatei datei = new GebietsDatei("Einkommen.csv");
|
||||
List<Gebiet> gebiet = datei.getGebiete();
|
||||
GebietsListe gebietsListe = new GebietsListe(gebiet);
|
||||
|
||||
System.out.println(gebietsListe.getAnzahlGesamt() + " Gebiete wurden eingelesen.");
|
||||
System.out.println(gebietsListe.getAnzahlUnvollständig() + " davon haben unvollständige Angaben.\n");
|
||||
|
||||
System.out.println("Gebiet mit dem geringsten Durchschnittseinkommen:");
|
||||
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);
|
||||
while (true) {
|
||||
System.out.print("Name des Gebietes: ");
|
||||
String input = sc.nextLine();
|
||||
if (input.isEmpty()) {
|
||||
break;
|
||||
}
|
||||
List<Gebiet> foundAreas = gebietsListe.getGebieteNachNamen(input);
|
||||
for (Gebiet area : foundAreas) {
|
||||
System.out.println(area);
|
||||
}
|
||||
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();
|
||||
}
|
||||
60
src/Gebiet.java
Normal file
60
src/Gebiet.java
Normal file
@@ -0,0 +1,60 @@
|
||||
public class Gebiet implements GebietInterface {
|
||||
private int jahr;
|
||||
private int schlüssel;
|
||||
private String name;
|
||||
private long gesamtEinkommen;
|
||||
private int durchschnittsEinkommen;
|
||||
|
||||
public Gebiet(int jahr, int schlüssel, String name, long gesamtEinkommen, int durchschnittsEinkommen) {
|
||||
this.jahr = jahr;
|
||||
this.schlüssel = schlüssel;
|
||||
this.name = name;
|
||||
this.gesamtEinkommen = gesamtEinkommen;
|
||||
this.durchschnittsEinkommen = durchschnittsEinkommen;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getJahr() {
|
||||
return jahr;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSchlüssel() {
|
||||
return schlüssel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getGesamtEinkommen() {
|
||||
if (gesamtEinkommen <= 0) {
|
||||
return -1;
|
||||
}
|
||||
return gesamtEinkommen;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDurchschnittsEinkommen() {
|
||||
if (durchschnittsEinkommen <= 0) {
|
||||
return -1;
|
||||
}
|
||||
return durchschnittsEinkommen;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAnzahlEinwohner() {
|
||||
return (int) (gesamtEinkommen * 1000 / durchschnittsEinkommen);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (getDurchschnittsEinkommen() <= 1 || getGesamtEinkommen() <= 1) {
|
||||
return getName() + "\n" + "Einwohnerzahl unbekannt\n" + "Durchschnittseinkommen unbekannt\n";
|
||||
}
|
||||
return getName() + "\n" + getAnzahlEinwohner() + " Einwohner\n" + getDurchschnittsEinkommen()
|
||||
+ " Euro / Einwohner\n";
|
||||
}
|
||||
}
|
||||
8
src/GebietInterface.java
Normal file
8
src/GebietInterface.java
Normal file
@@ -0,0 +1,8 @@
|
||||
public interface GebietInterface {
|
||||
int getJahr();
|
||||
int getSchlüssel();
|
||||
String getName();
|
||||
long getGesamtEinkommen();
|
||||
int getDurchschnittsEinkommen();
|
||||
int getAnzahlEinwohner();
|
||||
}
|
||||
39
src/GebietMock.java
Normal file
39
src/GebietMock.java
Normal file
@@ -0,0 +1,39 @@
|
||||
public class GebietMock implements GebietInterface{
|
||||
public GebietMock() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getJahr() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSchlüssel() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getGesamtEinkommen() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDurchschnittsEinkommen() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAnzahlEinwohner() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "GebietMock{}";
|
||||
}
|
||||
}
|
||||
27
src/GebietsDatei.java
Normal file
27
src/GebietsDatei.java
Normal file
@@ -0,0 +1,27 @@
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class GebietsDatei implements GebiesDateiInterface {
|
||||
|
||||
private String dateiName;
|
||||
|
||||
public GebietsDatei(String dateiName) {
|
||||
this.dateiName = dateiName;
|
||||
}
|
||||
|
||||
public ArrayList<Gebiet> getGebiete() {
|
||||
ArrayList<Gebiet> gebiete = new ArrayList<>();
|
||||
try {
|
||||
Files.readAllLines(Paths.get(dateiName)).forEach(line -> {
|
||||
String[] parts = line.split(";");
|
||||
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) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return gebiete;
|
||||
}
|
||||
}
|
||||
40
src/GebietsListe.java
Normal file
40
src/GebietsListe.java
Normal file
@@ -0,0 +1,40 @@
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class GebietsListe implements GebietsListeInterface{
|
||||
private List<Gebiet> gebiete = new ArrayList<>();
|
||||
|
||||
public GebietsListe(List<Gebiet> gebiete) {
|
||||
this.gebiete = gebiete;
|
||||
}
|
||||
|
||||
public Gebiet getGebietMinDurchschnittsEinkommen() {
|
||||
return gebiete.stream()
|
||||
.filter(g -> g.getDurchschnittsEinkommen() != -1)
|
||||
.min((g1, g2) -> g1.getDurchschnittsEinkommen() - g2.getDurchschnittsEinkommen())
|
||||
.get();
|
||||
}
|
||||
|
||||
public Gebiet getGebietMaxAnzahlEinwohner() {
|
||||
return gebiete.stream()
|
||||
.filter(g -> g.getDurchschnittsEinkommen() != -1)
|
||||
.max((g1, g2) -> g1.getAnzahlEinwohner() - g2.getAnzahlEinwohner())
|
||||
.get();
|
||||
}
|
||||
|
||||
public int getAnzahlGesamt() {
|
||||
return gebiete.size();
|
||||
}
|
||||
|
||||
public int getAnzahlUnvollständig() {
|
||||
return (int) gebiete.stream()
|
||||
.filter(g -> g.getDurchschnittsEinkommen() == -1 || g.getGesamtEinkommen() == -1)
|
||||
.count();
|
||||
}
|
||||
|
||||
public List<Gebiet> getGebieteNachNamen(String namensanfang) {
|
||||
return gebiete.stream()
|
||||
.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);
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Hello world!");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user