Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Variables
- int subscription = 0; //STORES SUBSCRIPTION INTEGER VALUE
- int moviesOnDemand = 0; //STORES MOVIES ON DEMAND INTEGER VALUE
- double cableSrvs = 0; //STORES TOTAL CABLE SERVICE DECIMAL VALUE
- double totalMovieCharges = 0; //STORES TOTAL MOVIE CHARGES DECIMAL VALUE
- double total = 0; //STORES TOTAL DECIMAL VALUE
- char confirm = 'Y'; //LOOP CONTROL VARIABLE SET TO Y
- Calendar dateTime = Calendar.getInstance(); //STORES THE DATE VALUE
- String customerName = "";
- while(Character.toUpperCase(confirm) == 'Y') //START OF WHILE LOOP AUTOMATICALLY ENTERS
- {
- String customer = setCustNm(customerName);
- double cable = setCablePkg(subscription);
- double type = determineCableSrv(subscription, cableSrvs);
- int movies = setMoviePurchase(moviesOnDemand);
- totalMovieCharges = movies * 7; //CALCULATING THE TOTAL MOVIE ON DEMAND CHARGE
- total = totalMovieCharges + type; //CALCULATING THE OVERALL TOTAL
- System.out.printf("%n%s %tD"
- + "nCustomer: %S"
- + "%n%nCable Service: $%,21.2f"
- + "%nMovies-On-Demand-HD: %,20.2f"
- + "nnTOTAL DUE: $%,21.2fn",
- "SA CABLE CHARGES AS OF", dateTime, customer, type,
- totalMovieCharges, total);
- input.nextLine();
- askNewSubscription(confirm);
- printThankYou(confirm);
- }
- }
- public static String setCustNm(String customerName)
- {
- // 1st prompt
- System.out.printf("%n%n%nWELCOME TO SA CABLE %n");
- System.out.printf("%nPlease enter your name: "); //PROMPTING USER TO ENTER NAME
- customerName = input.nextLine(); //CAPTURES USERS NAME
- return customerName;
- }
- public static int setCablePkg(int subscription)
- {
- do{
- // 2nd Prompt DISPLAYING THE DIFFERENT PACKAGES AVAILABLE FOR SUBSCRIPTION
- System.out.printf("%nSA CABLE - SUBSCRIPTION PACKAGES " +
- "%n%n1. Basic: Local & major TV network channels %s" +
- "%n2. Deluxe: Local, major TV, cable & 100 other channels %s" +
- "%n3. Premium: Deluxe package plus HEB, on-demand & 300 other channels %s",
- "$35.00", "75.00", "110.00") ;
- System.out.printf("%n%nSelect your cable subscription package: ");
- subscription = input.nextInt();//CAPTURING USER INPUT
- }while (subscription < 1 || subscription > 3);
- return subscription;
- }
- public static double determineCableSrv(int subscription, double cableSrvs)
- {
- if(subscription == 1) // IF STATEMENT TO IDENTIFY THE PRICE OF THE TOTAL CABLE SERVICE
- {
- cableSrvs = 35;
- }
- else if(subscription == 2)
- {
- cableSrvs = 75;
- }
- else if(subscription == 3)
- {
- cableSrvs = 110;
- }
- return cableSrvs;
- }
- public static int setMoviePurchase(int moviesOnDemand)
- {
- System.out.printf("%nSA CABLE - MOVIES " +
- "%n%nEnter the number of Movies-On-Demand-HD purchases: ");
- moviesOnDemand = input.nextInt();
- return moviesOnDemand;
- }
- public static char askNewSubscription(char confirm)
- {
- System.out.printf("nEnter 'Y' to continue with a new subscription or 'N' to exit: ");
- confirm = input.nextLine().charAt(0);
- return confirm;
- }
- public static char printThankYou(char confirm)
- {
- if(Character.toUpperCase(confirm) == 'Y')
- {
- confirm = 'Y';
- }
- if (Character.toUpperCase(confirm) != 'Y')
- {
- confirm = 'N';
- System.out.printf("Thank you for being a valued SA Cable customer!");
- System.exit(0);
- }
- return confirm;
- }
- public static double determineCableSrv(int subscription, double cableSrvs)
- {
- if(subscription == 1) // IF STATEMENT TO IDENTIFY THE PRICE OF THE TOTAL CABLE SERVICE
- {
- cableSrvs = 35;
- }
- else if(subscription == 2)
- {
- cableSrvs = 75;
- }
- else if(subscription == 3)
- {
- cableSrvs = 110;
- }
- return cableSrvs;
- }
- double type = determineCableSrv(subscription, cableSrvs);
- total = totalMovieCharges + type; //CALCULATING THE OVERALL TOTAL
- System.out.printf("%n%s %tD"
- + "nCustomer: %S"
- + "%n%nCable Service: $%,21.2f"
- + "%nMovies-On-Demand-HD: %,20.2f"
- + "nnTOTAL DUE: $%,21.2fn",
- "SA CABLE CHARGES AS OF", dateTime, customer, type,
- totalMovieCharges, total);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement