Advertisement
Guest User

Untitled

a guest
Feb 5th, 2016
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.73 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package contractmanager;
  7.  
  8. /**
  9. *
  10. * @author Nathan Hood
  11. */
  12.  
  13. import java.util.Scanner;
  14.  
  15. public class contract
  16. {
  17.  
  18. Scanner keyboard = new Scanner(System.in);
  19.  
  20. int amount=0;
  21.  
  22. String clientName;
  23.  
  24. do
  25. {
  26. System.out.println("Enter your Name");
  27. while (keyboard.hasNextInt())
  28. {
  29. System.out.println("That's not a name!");
  30. keyboard.next();
  31. System.out.println("Enter your Name");
  32. }
  33. clientName = keyboard.nextLine();
  34.  
  35. } while (clientName.equals(""));
  36.  
  37. // Package Selection
  38.  
  39. System.out.println("Enter your preferred package: ");
  40. System.out.println("1. Small");
  41. System.out.println("2. Medium");
  42. System.out.println("3. Large");
  43. int packageChoice = keyboard.nextInt();
  44. while (packageChoice <1 || packageChoice >3)
  45. {
  46. System.out.println("That's not a valid option");
  47. packageChoice = keyboard.nextInt();
  48. }
  49.  
  50. /*switch (packageChoice)
  51. {
  52. case 1:
  53. amount = 500;
  54. break;
  55. case 2:
  56. amount = 650;
  57. break;
  58. case 3:
  59. amount = 850;
  60. break;
  61. }
  62. */
  63.  
  64. System.out.println(amount);
  65.  
  66. // Data Bundle Selection
  67.  
  68. System.out.println("Enter your preferred data bundle: ");
  69. System.out.println("1. Low");
  70. System.out.println("2. Medium");
  71. System.out.println("3. High");
  72. int dataChoice = keyboard.nextInt();
  73. while (dataChoice <1 || dataChoice >3)
  74. {
  75. System.out.println("That's not a valid option");
  76. dataChoice = keyboard.nextInt();
  77. }
  78.  
  79. /*switch (dataChoice)
  80. {
  81. case 1:
  82. amount = amount + 500;
  83. break;
  84. case 2:
  85. amount = amount + 650;
  86. break;
  87. case 3:
  88. amount = amount + 850;
  89. break;
  90. }*/
  91.  
  92. // Reference Entry
  93.  
  94. System.out.println("Enter your reference");
  95. String reference = keyboard.next();
  96. String regex = "[A-Z]{2}[0-9]{3}[B|N]";
  97. boolean match = reference.matches(regex);
  98. while (match == false)
  99. {
  100. System.out.println("That isn't a valid reference");
  101. reference = keyboard.next();
  102. match = reference.matches(regex);
  103. }
  104.  
  105. char typeOfContract = reference.charAt(5);
  106.  
  107. System.out.println(typeOfContract);
  108.  
  109.  
  110.  
  111. // Contract Length Selection
  112.  
  113. System.out.println("Enter your contract length");
  114. System.out.println("1. 1 Month");
  115. System.out.println("2. 12 Months");
  116. System.out.println("3. 18 Months");
  117. System.out.println("4. 24 Months");
  118. int contractLength = keyboard.nextInt();
  119. while (contractLength <1 || contractLength >4)
  120. {
  121. System.out.println("That's not a valid option");
  122. contractLength = keyboard.nextInt();
  123. }
  124.  
  125.  
  126. // International Calls Selection
  127.  
  128. System.out.println("Would you like to include international calls?");
  129. System.out.println("1. Include");
  130. System.out.println("2. Do not Include");
  131. int intCallChoice = keyboard.nextInt();
  132. while (intCallChoice <1 || intCallChoice >2)
  133. {
  134. System.out.println("That's not a valid option");
  135. intCallChoice = keyboard.nextInt();
  136. }
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  143.  
  144.  
  145.  
  146.  
  147. public static void calculateCost(int packageChoice, int dataChoice, char typeOfContract, int contractLength, int intCallChoice)
  148. {
  149.  
  150. int[][] prices =
  151. {
  152. {500, 600, 700},
  153. {650, 850, 1050},
  154. {850, 1050, 1250, 2000}
  155. };
  156.  
  157.  
  158. double priceOfBundle = prices [packageChoice - 1][dataChoice -1];
  159.  
  160. if (typeOfContract == 'B' || contractLength == 4)
  161. {
  162. priceOfBundle *= 0.9;
  163. }
  164. else if (contractLength == 2 || contractLength == 3)
  165. {
  166. priceOfBundle *= 0.95;
  167. }
  168.  
  169. if (intCallChoice == 1)
  170. {
  171. priceOfBundle *= 1.15;
  172. }
  173.  
  174. double contractCost = (int) Math.round(priceOfBundle);
  175. }
  176. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement