Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2014
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.22 KB | None | 0 0
  1. //Variables
  2.  
  3. int subscription = 0; //STORES SUBSCRIPTION INTEGER VALUE
  4. int moviesOnDemand = 0; //STORES MOVIES ON DEMAND INTEGER VALUE
  5. double cableSrvs = 0; //STORES TOTAL CABLE SERVICE DECIMAL VALUE
  6. double totalMovieCharges = 0; //STORES TOTAL MOVIE CHARGES DECIMAL VALUE
  7. double total = 0; //STORES TOTAL DECIMAL VALUE
  8. char confirm = 'Y'; //LOOP CONTROL VARIABLE SET TO Y
  9. Calendar dateTime = Calendar.getInstance(); //STORES THE DATE VALUE
  10. String customerName = "";
  11.  
  12.  
  13. while(Character.toUpperCase(confirm) == 'Y') //START OF WHILE LOOP AUTOMATICALLY ENTERS
  14. {
  15. String customer = setCustNm(customerName);
  16.  
  17.  
  18. double cable = setCablePkg(subscription);
  19.  
  20. double type = determineCableSrv(subscription, cableSrvs);
  21.  
  22. int movies = setMoviePurchase(moviesOnDemand);
  23.  
  24. totalMovieCharges = movies * 7; //CALCULATING THE TOTAL MOVIE ON DEMAND CHARGE
  25. total = totalMovieCharges + type; //CALCULATING THE OVERALL TOTAL
  26.  
  27.  
  28.  
  29.  
  30. System.out.printf("%n%s %tD"
  31. + "nCustomer: %S"
  32. + "%n%nCable Service: $%,21.2f"
  33. + "%nMovies-On-Demand-HD: %,20.2f"
  34. + "nnTOTAL DUE: $%,21.2fn",
  35. "SA CABLE CHARGES AS OF", dateTime, customer, type,
  36. totalMovieCharges, total);
  37.  
  38. input.nextLine();
  39.  
  40.  
  41. askNewSubscription(confirm);
  42.  
  43. printThankYou(confirm);
  44.  
  45. }
  46. }
  47.  
  48. public static String setCustNm(String customerName)
  49.  
  50. {
  51.  
  52. // 1st prompt
  53. System.out.printf("%n%n%nWELCOME TO SA CABLE %n");
  54. System.out.printf("%nPlease enter your name: "); //PROMPTING USER TO ENTER NAME
  55. customerName = input.nextLine(); //CAPTURES USERS NAME
  56.  
  57. return customerName;
  58. }
  59.  
  60. public static int setCablePkg(int subscription)
  61. {
  62. do{
  63. // 2nd Prompt DISPLAYING THE DIFFERENT PACKAGES AVAILABLE FOR SUBSCRIPTION
  64. System.out.printf("%nSA CABLE - SUBSCRIPTION PACKAGES " +
  65. "%n%n1. Basic: Local & major TV network channels %s" +
  66. "%n2. Deluxe: Local, major TV, cable & 100 other channels %s" +
  67. "%n3. Premium: Deluxe package plus HEB, on-demand & 300 other channels %s",
  68. "$35.00", "75.00", "110.00") ;
  69.  
  70. System.out.printf("%n%nSelect your cable subscription package: ");
  71. subscription = input.nextInt();//CAPTURING USER INPUT
  72.  
  73. }while (subscription < 1 || subscription > 3);
  74.  
  75. return subscription;
  76. }
  77.  
  78. public static double determineCableSrv(int subscription, double cableSrvs)
  79. {
  80.  
  81. if(subscription == 1) // IF STATEMENT TO IDENTIFY THE PRICE OF THE TOTAL CABLE SERVICE
  82. {
  83. cableSrvs = 35;
  84. }
  85. else if(subscription == 2)
  86. {
  87. cableSrvs = 75;
  88. }
  89. else if(subscription == 3)
  90. {
  91. cableSrvs = 110;
  92. }
  93. return cableSrvs;
  94.  
  95. }
  96.  
  97.  
  98.  
  99. public static int setMoviePurchase(int moviesOnDemand)
  100. {
  101. System.out.printf("%nSA CABLE - MOVIES " +
  102. "%n%nEnter the number of Movies-On-Demand-HD purchases: ");
  103. moviesOnDemand = input.nextInt();
  104. return moviesOnDemand;
  105. }
  106.  
  107.  
  108. public static char askNewSubscription(char confirm)
  109. {
  110. System.out.printf("nEnter 'Y' to continue with a new subscription or 'N' to exit: ");
  111. confirm = input.nextLine().charAt(0);
  112.  
  113. return confirm;
  114.  
  115. }
  116.  
  117.  
  118. public static char printThankYou(char confirm)
  119. {
  120.  
  121. if(Character.toUpperCase(confirm) == 'Y')
  122. {
  123. confirm = 'Y';
  124. }
  125. if (Character.toUpperCase(confirm) != 'Y')
  126. {
  127. confirm = 'N';
  128. System.out.printf("Thank you for being a valued SA Cable customer!");
  129.  
  130. System.exit(0);
  131. }
  132.  
  133. return confirm;
  134. }
  135.  
  136. public static double determineCableSrv(int subscription, double cableSrvs)
  137. {
  138.  
  139. if(subscription == 1) // IF STATEMENT TO IDENTIFY THE PRICE OF THE TOTAL CABLE SERVICE
  140. {
  141. cableSrvs = 35;
  142. }
  143. else if(subscription == 2)
  144. {
  145. cableSrvs = 75;
  146. }
  147. else if(subscription == 3)
  148. {
  149. cableSrvs = 110;
  150. }
  151. return cableSrvs;
  152.  
  153. }
  154.  
  155. double type = determineCableSrv(subscription, cableSrvs);
  156.  
  157. total = totalMovieCharges + type; //CALCULATING THE OVERALL TOTAL
  158.  
  159. System.out.printf("%n%s %tD"
  160. + "nCustomer: %S"
  161. + "%n%nCable Service: $%,21.2f"
  162. + "%nMovies-On-Demand-HD: %,20.2f"
  163. + "nnTOTAL DUE: $%,21.2fn",
  164. "SA CABLE CHARGES AS OF", dateTime, customer, type,
  165. totalMovieCharges, total);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement