Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ui;
- import domain.Huis;
- import java.util.Scanner;
- public class HuisApp {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- int oppervlakte;
- int aantalKamers;
- double belastingVoet = 0;
- double verkoopPrijs = 0;
- String stad = "";
- String type;
- int tellervilla = 0;
- int tellerbungalow = 0;
- int tellerhalfopen = 0;
- int tellerrijhuis = 0;
- Huis mijnHuis;
- String antwoord = "";
- String antwoord2 = "";
- do {
- System.out.print("Wil je een huis blouwen? (j/n): ");
- antwoord = sc.next();
- antwoord = antwoord.toLowerCase();
- } while (antwoord.charAt(0) != 'j' && antwoord.charAt(0) != 'n');
- while (antwoord.charAt(0) == 'j') {
- do {
- System.out.print("Wat is de oppervlakte? (positief getal): ");
- oppervlakte = sc.nextInt();
- } while (oppervlakte <= 0);
- do {
- System.out.print("Hoeveel kamers zijn er? (positief getal): ");
- aantalKamers = sc.nextInt();
- } while (aantalKamers <= 0);
- do {
- System.out.print("In welke stad wordt er gebouwd? (Gent, Brussel of Antwerpen): ");
- stad = sc.next();
- stad = stad.toLowerCase();
- } while (!"gent".equals(stad) && !"brussel".equals(stad) && !"antwerpen".equals(stad));
- switch (stad) {
- case "gent":
- belastingVoet = 0.07;
- break;
- case "brussel":
- belastingVoet = 0.17;
- break;
- case "antwerpen":
- belastingVoet = 0.11;
- break;
- }
- mijnHuis = new Huis(oppervlakte, aantalKamers, belastingVoet);
- do {
- System.out.print("Zijn de type en de verkoopprijs al gekend? (j/n): ");
- antwoord2 = sc.next();
- antwoord2 = antwoord2.toLowerCase();
- } while (antwoord.charAt(0) != 'j' && antwoord.charAt(0) != 'n');
- if (antwoord2.charAt(0) == 'n') {
- System.out.println(mijnHuis.toString());
- } else {
- do {
- System.out.print("Verkoopprijs? (positief getal): ");
- verkoopPrijs = sc.nextDouble();
- } while (verkoopPrijs <= 0);
- do {
- System.out.print("Type? (v, h, r, b): ");
- type = sc.next();
- } while (type.charAt(0) != 'v' && type.charAt(0) != 'h' && type.charAt(0) != 'r' && type.charAt(0) != 'b');
- switch (type.charAt(0)) {
- case 'v':
- tellervilla++;
- break;
- case 'h':
- tellerhalfopen++;
- break;
- case 'r':
- tellerrijhuis++;
- break;
- case 'b':
- tellerbungalow++;
- break;
- }
- mijnHuis = new Huis(oppervlakte, aantalKamers, belastingVoet, verkoopPrijs, type.charAt(0));
- System.out.println(mijnHuis.toString());
- }
- do {
- System.out.print("Wil je een huis blouwen? (j/n): ");
- antwoord = sc.next();
- antwoord = antwoord.toLowerCase();
- } while (antwoord.charAt(0) != 'j' && antwoord.charAt(0) != 'n');
- }
- if (tellerbungalow == 1) {
- System.out.print("Je hebt" + tellerbungalow + "bungalow, ");
- } else {
- System.out.print("Je hebt" + tellerbungalow + "bungalows, ");
- }
- if (tellerhalfopen == 1) {
- System.out.print(tellerhalfopen + " half open bebouwingen, ");
- } else {
- System.out.print(tellerhalfopen + "half open bebouwingen, ");
- }
- if (tellerrijhuis == 1) {
- System.out.print(tellerrijhuis + "rijhuis en ");
- } else {
- System.out.print(tellerrijhuis + "rijhuizen en ");
- }
- if (tellervilla == 1) {
- System.out.print(tellervilla + "villa gebouwd");
- } else {
- System.out.print(tellervilla + "villas gebouwd");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement