alexandra84

BillingFinal

Nov 1st, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.97 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class waterwork_modul2 {
  4.  
  5. public static void main(String[] args) {
  6. billingSettings();
  7. }
  8.  
  9.  
  10. private static void billingSettings() {
  11. boolean quit = false;
  12. int settingID =0;
  13.  
  14. Scanner input = new Scanner(System.in);
  15.  
  16.  
  17. System.out.println("Billing Settings");
  18.  
  19.  
  20. //Select and display billing data from sql payment table
  21. DB.selectSQL("SELECT * FROM tblSettings");
  22. System.out.println("numberOfColumns="+DB.getNumberOfColumns());
  23.  
  24. do{
  25. String data = DB.getDisplayData();
  26. if (data.equals(DB.NOMOREDATA)){
  27. break;
  28. }
  29. else
  30. System.out.print(data);
  31. }
  32. while (true);
  33.  
  34.  
  35. do {
  36.  
  37. int menuItem; //This will save your menu choice
  38.  
  39. System.out.println("/////////////////////////////////////////");
  40. System.out.println("Press '1' for: Yes");
  41. System.out.println("Press '2' for No");
  42. System.out.print("Enter your choice here: ");
  43. menuItem = validateIntInput(); //Keep this to validate menu
  44. System.out.println("/////////////////////////////////////////");
  45.  
  46. switch (menuItem) {
  47. case 1:
  48.  
  49. do {
  50.  
  51. System.out.println("/////////////////////////////////////////");
  52. System.out.print("Please choose which setting would you like to change:");
  53. System.out.println();
  54. System.out.println("Press '1' for: Manual Fee Rate Industrial");
  55. System.out.println("Press '2' for: Manual Fee Rate Private");
  56. System.out.println("Press '3' for: Manual Fee Rate Agricultural");
  57. System.out.println("Press '4' for: Water Tax Rate Industrial");
  58. System.out.println("Press '5' for: Water Tax Rate Agricultural");
  59. System.out.println("Press '6' for: Water Tax Rate Private");
  60. System.out.println("Press '7' for: Drainage Tax Rate Private");
  61. System.out.println("Press '8' for: Drainage Tax Rate Agricultural");
  62. System.out.println("Press '9' for: Drainage Tax Rate Industrial");
  63. System.out.println("Press '10' for: Basic Water Price");
  64. System.out.println("Press '11' for: Go back to main menu");
  65.  
  66.  
  67. menuItem = validateIntInput(); //Keep this to validate menu
  68. System.out.println("/////////////////////////////////////////");
  69.  
  70. switch (menuItem) {
  71. case 1:
  72. System.out.println("Please input the new value:");
  73. double manualFeeRateIndustrial = input.nextDouble();
  74. //Update data in Manual Fee Rate Industrial field
  75. DB.updateSQL("UPDATE tblSettings SET fldManualFeeRateIndustrial=" + manualFeeRateIndustrial + "");
  76. System.out.println("Manual Fee Rate Industrial has been changed to " + manualFeeRateIndustrial);
  77. break;
  78.  
  79. case 2:
  80. System.out.println("Please input the new value:");//Enter the code that needs to run if 1 was the option choosed.
  81. double manualFeeRatePrivate = input.nextDouble();
  82. //Update data in Manual Fee Rate Private field
  83. DB.updateSQL("UPDATE tblSettings SET fldManualFeeRatePrivate= "+manualFeeRatePrivate+"");
  84. break;
  85.  
  86. case 3:
  87. System.out.println("Please input the new value:");
  88. double manualFeeRateAgriculture = input.nextDouble();
  89. //Update data in Manual Fee Rate Agriculture field
  90. DB.updateSQL("UPDATE tblSettings SET fldManualFeeRateAgriculture= "+manualFeeRateAgriculture+"");
  91. break;
  92.  
  93. case 4:
  94. System.out.println("Please input the new value:");
  95. double waterTaxRateIndustrial = input.nextDouble();
  96. //Update data in Water Tax Rate Industrial field
  97. DB.updateSQL("UPDATE tblSettings SET fldWaterTaxRateIndustrial= "+waterTaxRateIndustrial+"");
  98. break;
  99.  
  100. case 5:
  101. System.out.println("Please input the new value:");
  102. double waterTaxRateAgriculture = input.nextDouble();
  103. //Update data in Water Tax Rate Agriculture field
  104. DB.updateSQL("UPDATE tblSettings SET fldWaterTaxRateAgriculture= "+waterTaxRateAgriculture+"");
  105. break;
  106.  
  107. case 6:
  108. System.out.println("Please input the new value:");
  109. double waterTaxRatePrivate = input.nextDouble();
  110. //Update data in Water Tax Rate Private field
  111. DB.updateSQL("UPDATE tblSettings SET fldWaterTaxRatePrivate= "+waterTaxRatePrivate+"");
  112. break;
  113.  
  114. case 7:
  115. System.out.println("Please input the new value:");
  116. double drainageTaxRateAgriculture = input.nextDouble();
  117. //Update data in Drainage Tax Rate Agriculture field
  118. DB.updateSQL("UPDATE tblSettings SET fldDrainageTaxRateAgriculture= "+drainageTaxRateAgriculture+"");
  119. break;
  120.  
  121. case 8:
  122. System.out.println("Please input the new value:");
  123. double drainageTaxRatePrivate = input.nextDouble();
  124. //Update data in Drainage Tax Rate Private field
  125. DB.updateSQL("UPDATE tblSettings SET fldDrainageTaxRatePrivate= "+drainageTaxRatePrivate+"");
  126. break;
  127.  
  128. case 9:
  129. System.out.println("Please input the new value:");
  130. double drainageTaxRateIndustrial = input.nextDouble();
  131. //Update data in Drainage Tax Rate Industrial field
  132. DB.updateSQL("UPDATE tblSettings SET fldDrainageTaxRateIndustrial= "+drainageTaxRateIndustrial+"");
  133. break;
  134.  
  135. case 10:
  136. System.out.println("Please input the new value:");
  137. double basicWaterPrice = input.nextDouble();
  138. //Update data in Basic Water Price field
  139. DB.updateSQL("UPDATE tblSettings SET fldBasicWaterPrice= "+basicWaterPrice+"");
  140. break;
  141.  
  142. case 11:
  143. quit = true; //This will make the loop stop after running the program - Used when user want to go back
  144. break;
  145. default:
  146. System.out.println("Invalid choice. Try again: ");
  147. }
  148.  
  149. } while (!quit);
  150. break;
  151.  
  152. case 2:
  153. //Enter the code that needs to run if 2 was the option choosed.
  154. quit = true; //This will make the loop stop after running the program - Used when user want to go back
  155. break;
  156. default:
  157. System.out.println("Invalid choice. Try again: ");
  158. }
  159.  
  160. } while (!quit);
  161.  
  162.  
  163. }
  164.  
  165. private static int validateIntInput() {
  166. // VALIDATES IF THE INPUT IS AN INT
  167. Scanner input = new Scanner(System.in);
  168. while (true) {
  169. //System.out.println("1: Billing");
  170. //System.out.println("2: Economy:");
  171. //System.out.println("3: Statistics");
  172. //System.out.println("0. Quit");
  173. try {
  174. int a = input.nextInt();
  175. if (a == 0) {
  176. return 0;
  177. } else {
  178. return a;
  179. }
  180. } catch (java.util.InputMismatchException e) {
  181. System.out.println("You didn't enter a number - Try again: ");
  182. input.nextLine();
  183. }
  184. }
  185.  
  186.  
  187. }
  188.  
  189. }
Add Comment
Please, Sign In to add comment