Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class waterwork_modul2 {
- public static void main(String[] args) {
- billingSettings();
- }
- private static void billingSettings() {
- boolean quit = false;
- int settingID =0;
- Scanner input = new Scanner(System.in);
- System.out.println("Billing Settings");
- //Select and display billing data from sql payment table
- DB.selectSQL("SELECT * FROM tblSettings");
- System.out.println("numberOfColumns="+DB.getNumberOfColumns());
- do{
- String data = DB.getDisplayData();
- if (data.equals(DB.NOMOREDATA)){
- break;
- }
- else
- System.out.print(data);
- }
- while (true);
- do {
- int menuItem; //This will save your menu choice
- System.out.println("/////////////////////////////////////////");
- System.out.println("Press '1' for: Yes");
- System.out.println("Press '2' for No");
- System.out.print("Enter your choice here: ");
- menuItem = validateIntInput(); //Keep this to validate menu
- System.out.println("/////////////////////////////////////////");
- switch (menuItem) {
- case 1:
- do {
- System.out.println("/////////////////////////////////////////");
- System.out.print("Please choose which setting would you like to change:");
- System.out.println();
- System.out.println("Press '1' for: Manual Fee Rate Industrial");
- System.out.println("Press '2' for: Manual Fee Rate Private");
- System.out.println("Press '3' for: Manual Fee Rate Agricultural");
- System.out.println("Press '4' for: Water Tax Rate Industrial");
- System.out.println("Press '5' for: Water Tax Rate Agricultural");
- System.out.println("Press '6' for: Water Tax Rate Private");
- System.out.println("Press '7' for: Drainage Tax Rate Private");
- System.out.println("Press '8' for: Drainage Tax Rate Agricultural");
- System.out.println("Press '9' for: Drainage Tax Rate Industrial");
- System.out.println("Press '10' for: Basic Water Price");
- System.out.println("Press '11' for: Go back to main menu");
- menuItem = validateIntInput(); //Keep this to validate menu
- System.out.println("/////////////////////////////////////////");
- switch (menuItem) {
- case 1:
- System.out.println("Please input the new value:");
- double manualFeeRateIndustrial = input.nextDouble();
- //Update data in Manual Fee Rate Industrial field
- DB.updateSQL("UPDATE tblSettings SET fldManualFeeRateIndustrial=" + manualFeeRateIndustrial + "");
- System.out.println("Manual Fee Rate Industrial has been changed to " + manualFeeRateIndustrial);
- break;
- case 2:
- System.out.println("Please input the new value:");//Enter the code that needs to run if 1 was the option choosed.
- double manualFeeRatePrivate = input.nextDouble();
- //Update data in Manual Fee Rate Private field
- DB.updateSQL("UPDATE tblSettings SET fldManualFeeRatePrivate= "+manualFeeRatePrivate+"");
- break;
- case 3:
- System.out.println("Please input the new value:");
- double manualFeeRateAgriculture = input.nextDouble();
- //Update data in Manual Fee Rate Agriculture field
- DB.updateSQL("UPDATE tblSettings SET fldManualFeeRateAgriculture= "+manualFeeRateAgriculture+"");
- break;
- case 4:
- System.out.println("Please input the new value:");
- double waterTaxRateIndustrial = input.nextDouble();
- //Update data in Water Tax Rate Industrial field
- DB.updateSQL("UPDATE tblSettings SET fldWaterTaxRateIndustrial= "+waterTaxRateIndustrial+"");
- break;
- case 5:
- System.out.println("Please input the new value:");
- double waterTaxRateAgriculture = input.nextDouble();
- //Update data in Water Tax Rate Agriculture field
- DB.updateSQL("UPDATE tblSettings SET fldWaterTaxRateAgriculture= "+waterTaxRateAgriculture+"");
- break;
- case 6:
- System.out.println("Please input the new value:");
- double waterTaxRatePrivate = input.nextDouble();
- //Update data in Water Tax Rate Private field
- DB.updateSQL("UPDATE tblSettings SET fldWaterTaxRatePrivate= "+waterTaxRatePrivate+"");
- break;
- case 7:
- System.out.println("Please input the new value:");
- double drainageTaxRateAgriculture = input.nextDouble();
- //Update data in Drainage Tax Rate Agriculture field
- DB.updateSQL("UPDATE tblSettings SET fldDrainageTaxRateAgriculture= "+drainageTaxRateAgriculture+"");
- break;
- case 8:
- System.out.println("Please input the new value:");
- double drainageTaxRatePrivate = input.nextDouble();
- //Update data in Drainage Tax Rate Private field
- DB.updateSQL("UPDATE tblSettings SET fldDrainageTaxRatePrivate= "+drainageTaxRatePrivate+"");
- break;
- case 9:
- System.out.println("Please input the new value:");
- double drainageTaxRateIndustrial = input.nextDouble();
- //Update data in Drainage Tax Rate Industrial field
- DB.updateSQL("UPDATE tblSettings SET fldDrainageTaxRateIndustrial= "+drainageTaxRateIndustrial+"");
- break;
- case 10:
- System.out.println("Please input the new value:");
- double basicWaterPrice = input.nextDouble();
- //Update data in Basic Water Price field
- DB.updateSQL("UPDATE tblSettings SET fldBasicWaterPrice= "+basicWaterPrice+"");
- break;
- case 11:
- quit = true; //This will make the loop stop after running the program - Used when user want to go back
- break;
- default:
- System.out.println("Invalid choice. Try again: ");
- }
- } while (!quit);
- break;
- case 2:
- //Enter the code that needs to run if 2 was the option choosed.
- quit = true; //This will make the loop stop after running the program - Used when user want to go back
- break;
- default:
- System.out.println("Invalid choice. Try again: ");
- }
- } while (!quit);
- }
- private static int validateIntInput() {
- // VALIDATES IF THE INPUT IS AN INT
- Scanner input = new Scanner(System.in);
- while (true) {
- //System.out.println("1: Billing");
- //System.out.println("2: Economy:");
- //System.out.println("3: Statistics");
- //System.out.println("0. Quit");
- try {
- int a = input.nextInt();
- if (a == 0) {
- return 0;
- } else {
- return a;
- }
- } catch (java.util.InputMismatchException e) {
- System.out.println("You didn't enter a number - Try again: ");
- input.nextLine();
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment