Advertisement
Guest User

Untitled

a guest
Nov 14th, 2018
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.47 KB | None | 0 0
  1. package ui;
  2.  
  3. import domain.Huis;
  4. import java.util.Scanner;
  5.  
  6. public class HuisApp {
  7.  
  8. public static void main(String[] args) {
  9.  
  10. Scanner sc = new Scanner(System.in);
  11. int oppervlakte;
  12. int aantalKamers;
  13. double belastingVoet = 0;
  14. double verkoopPrijs = 0;
  15. String stad = "";
  16. String type;
  17. int tellervilla = 0;
  18. int tellerbungalow = 0;
  19. int tellerhalfopen = 0;
  20. int tellerrijhuis = 0;
  21.  
  22. Huis mijnHuis;
  23.  
  24. String antwoord = "";
  25. String antwoord2 = "";
  26.  
  27. do {
  28. System.out.print("Wil je een huis blouwen? (j/n): ");
  29. antwoord = sc.next();
  30. antwoord = antwoord.toLowerCase();
  31. } while (antwoord.charAt(0) != 'j' && antwoord.charAt(0) != 'n');
  32. while (antwoord.charAt(0) == 'j') {
  33. do {
  34. System.out.print("Wat is de oppervlakte? (positief getal): ");
  35. oppervlakte = sc.nextInt();
  36. } while (oppervlakte <= 0);
  37. do {
  38. System.out.print("Hoeveel kamers zijn er? (positief getal): ");
  39. aantalKamers = sc.nextInt();
  40. } while (aantalKamers <= 0);
  41. do {
  42. System.out.print("In welke stad wordt er gebouwd? (Gent, Brussel of Antwerpen): ");
  43. stad = sc.next();
  44. stad = stad.toLowerCase();
  45. } while (!"gent".equals(stad) && !"brussel".equals(stad) && !"antwerpen".equals(stad));
  46.  
  47. switch (stad) {
  48. case "gent":
  49. belastingVoet = 0.07;
  50. break;
  51. case "brussel":
  52. belastingVoet = 0.17;
  53. break;
  54. case "antwerpen":
  55. belastingVoet = 0.11;
  56. break;
  57.  
  58. }
  59. mijnHuis = new Huis(oppervlakte, aantalKamers, belastingVoet);
  60. do {
  61. System.out.print("Zijn de type en de verkoopprijs al gekend? (j/n): ");
  62. antwoord2 = sc.next();
  63. antwoord2 = antwoord2.toLowerCase();
  64. } while (antwoord.charAt(0) != 'j' && antwoord.charAt(0) != 'n');
  65. if (antwoord2.charAt(0) == 'n') {
  66. System.out.println(mijnHuis.toString());
  67. } else {
  68. do {
  69. System.out.print("Verkoopprijs? (positief getal): ");
  70. verkoopPrijs = sc.nextDouble();
  71. } while (verkoopPrijs <= 0);
  72.  
  73. do {
  74. System.out.print("Type? (v, h, r, b): ");
  75. type = sc.next();
  76. } while (type.charAt(0) != 'v' && type.charAt(0) != 'h' && type.charAt(0) != 'r' && type.charAt(0) != 'b');
  77. switch (type.charAt(0)) {
  78. case 'v':
  79. tellervilla++;
  80. break;
  81. case 'h':
  82. tellerhalfopen++;
  83. break;
  84. case 'r':
  85. tellerrijhuis++;
  86. break;
  87. case 'b':
  88. tellerbungalow++;
  89. break;
  90. }
  91. mijnHuis = new Huis(oppervlakte, aantalKamers, belastingVoet, verkoopPrijs, type.charAt(0));
  92. System.out.println(mijnHuis.toString());
  93. }
  94.  
  95. do {
  96. System.out.print("Wil je een huis blouwen? (j/n): ");
  97. antwoord = sc.next();
  98. antwoord = antwoord.toLowerCase();
  99. } while (antwoord.charAt(0) != 'j' && antwoord.charAt(0) != 'n');
  100. }
  101. if (tellerbungalow == 1) {
  102. System.out.print("Je hebt" + tellerbungalow + "bungalow, ");
  103. } else {
  104. System.out.print("Je hebt" + tellerbungalow + "bungalows, ");
  105. }
  106. if (tellerhalfopen == 1) {
  107. System.out.print(tellerhalfopen + " half open bebouwingen, ");
  108. } else {
  109. System.out.print(tellerhalfopen + "half open bebouwingen, ");
  110. }
  111. if (tellerrijhuis == 1) {
  112. System.out.print(tellerrijhuis + "rijhuis en ");
  113. } else {
  114. System.out.print(tellerrijhuis + "rijhuizen en ");
  115. }
  116. if (tellervilla == 1) {
  117. System.out.print(tellervilla + "villa gebouwd");
  118. } else {
  119. System.out.print(tellervilla + "villas gebouwd");
  120. }
  121.  
  122. }
  123.  
  124. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement