Compare commits
13 Commits
readfile
...
90a323ce01
Author | SHA1 | Date | |
---|---|---|---|
90a323ce01 | |||
0643732d08 | |||
7ca888121d | |||
da5bcc93bf | |||
![]() |
81b4cbeb7e | ||
![]() |
aab1fe68d7 | ||
![]() |
8382a47d7e | ||
daf0ec541d | |||
268f4eee43 | |||
a2bd838467 | |||
78dfa848fa | |||
![]() |
2562126caa | ||
9c6592fbff |
@@ -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;01001;Flensburg, Kreisfreie Stadt;1602046;18481
|
||||||
2016;01002;Kiel, Landeshauptstadt, Kreisfreie Stadt;4643584;18810
|
2016;01002;Kiel, Landeshauptstadt, Kreisfreie Stadt;4643584;18810
|
||||||
2016;01003;Lübeck, Hansestadt, Kreisfreie Stadt;4237638;19575
|
2016;01003;Lübeck, Hansestadt, Kreisfreie Stadt;4237638;19575
|
||||||
|
|
29
src/EinkommenInfo.java
Normal file
29
src/EinkommenInfo.java
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
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(gebiet.size() + " Gebiete wurden eingelesen.");
|
||||||
|
System.out.println(gebietsListe.getAnzahlUnvollstaendig() + " davon haben unvollständige Angaben.");
|
||||||
|
System.out.println();
|
||||||
|
System.out.println("Gebiet mit dem geringsten Durchschnittseinkommen:");
|
||||||
|
System.out.println(gebietsListe.getGebietMinDurchschnittEinkommen());
|
||||||
|
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.getGebietNachNamen(input);
|
||||||
|
for (Gebiet area : foundAreas) {
|
||||||
|
System.out.println(area);
|
||||||
|
}
|
||||||
|
System.out.println(foundAreas.size() + " Gebiete wurden gefunden.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
public class Gebiet implements GebietInterface{
|
public class Gebiet implements GebietInterface{
|
||||||
private int jahr;
|
private int jahr;
|
||||||
private int schlüssel;
|
private int schlüssel;
|
||||||
@@ -31,16 +30,27 @@ public class Gebiet implements GebietInterface{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getGesamtEinkommen() {
|
public long getGesamtEinkommen() {
|
||||||
|
if(gesamtEinkommen <= 0){
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
return gesamtEinkommen;
|
return gesamtEinkommen;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getDurchschnittsEinkommen() {
|
public int getDurchschnittsEinkommen() {
|
||||||
|
if(durchschnittsEinkommen <= 0){
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
return durchschnittsEinkommen;
|
return durchschnittsEinkommen;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getAnzahlEinwohner() {
|
public int getAnzahlEinwohner() {
|
||||||
return 0;
|
return (int)(gesamtEinkommen / durchschnittsEinkommen);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return getName() + "\n" + getAnzahlEinwohner() + " Einwohner\n" + getDurchschnittsEinkommen() + " Euro / Einwohner\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -15,7 +15,7 @@ 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], Long.parseLong(parts[3]), Integer.parseInt(parts[4])));
|
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])));
|
||||||
});
|
});
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@@ -1,3 +1,34 @@
|
|||||||
public class GebietsListe {
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class GebietsListe {
|
||||||
|
private List<GebietMock> gebietListe = new ArrayList<>();
|
||||||
|
|
||||||
|
public GebietsListe(List<Gebiet> gebiete){
|
||||||
|
this.gebietListe = gebietListe;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Gebiet getGebietMinDurchschnittEinkommen(){
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Gebiet getGebietMaxEinwohner(){
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAnzahlGesamt(){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getAnzahlUnvollstaendig(){
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Gebiet> getGebietNachNamen(String namensanfang){
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -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