Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package contractmanager;
- /**
- *
- * @author Nathan Hood
- */
- import java.util.Scanner;
- public class contract
- {
- Scanner keyboard = new Scanner(System.in);
- int amount=0;
- String clientName;
- do
- {
- System.out.println("Enter your Name");
- while (keyboard.hasNextInt())
- {
- System.out.println("That's not a name!");
- keyboard.next();
- System.out.println("Enter your Name");
- }
- clientName = keyboard.nextLine();
- } while (clientName.equals(""));
- // Package Selection
- System.out.println("Enter your preferred package: ");
- System.out.println("1. Small");
- System.out.println("2. Medium");
- System.out.println("3. Large");
- int packageChoice = keyboard.nextInt();
- while (packageChoice <1 || packageChoice >3)
- {
- System.out.println("That's not a valid option");
- packageChoice = keyboard.nextInt();
- }
- /*switch (packageChoice)
- {
- case 1:
- amount = 500;
- break;
- case 2:
- amount = 650;
- break;
- case 3:
- amount = 850;
- break;
- }
- */
- System.out.println(amount);
- // Data Bundle Selection
- System.out.println("Enter your preferred data bundle: ");
- System.out.println("1. Low");
- System.out.println("2. Medium");
- System.out.println("3. High");
- int dataChoice = keyboard.nextInt();
- while (dataChoice <1 || dataChoice >3)
- {
- System.out.println("That's not a valid option");
- dataChoice = keyboard.nextInt();
- }
- /*switch (dataChoice)
- {
- case 1:
- amount = amount + 500;
- break;
- case 2:
- amount = amount + 650;
- break;
- case 3:
- amount = amount + 850;
- break;
- }*/
- // Reference Entry
- System.out.println("Enter your reference");
- String reference = keyboard.next();
- String regex = "[A-Z]{2}[0-9]{3}[B|N]";
- boolean match = reference.matches(regex);
- while (match == false)
- {
- System.out.println("That isn't a valid reference");
- reference = keyboard.next();
- match = reference.matches(regex);
- }
- char typeOfContract = reference.charAt(5);
- System.out.println(typeOfContract);
- // Contract Length Selection
- System.out.println("Enter your contract length");
- System.out.println("1. 1 Month");
- System.out.println("2. 12 Months");
- System.out.println("3. 18 Months");
- System.out.println("4. 24 Months");
- int contractLength = keyboard.nextInt();
- while (contractLength <1 || contractLength >4)
- {
- System.out.println("That's not a valid option");
- contractLength = keyboard.nextInt();
- }
- // International Calls Selection
- System.out.println("Would you like to include international calls?");
- System.out.println("1. Include");
- System.out.println("2. Do not Include");
- int intCallChoice = keyboard.nextInt();
- while (intCallChoice <1 || intCallChoice >2)
- {
- System.out.println("That's not a valid option");
- intCallChoice = keyboard.nextInt();
- }
- public static void calculateCost(int packageChoice, int dataChoice, char typeOfContract, int contractLength, int intCallChoice)
- {
- int[][] prices =
- {
- {500, 600, 700},
- {650, 850, 1050},
- {850, 1050, 1250, 2000}
- };
- double priceOfBundle = prices [packageChoice - 1][dataChoice -1];
- if (typeOfContract == 'B' || contractLength == 4)
- {
- priceOfBundle *= 0.9;
- }
- else if (contractLength == 2 || contractLength == 3)
- {
- priceOfBundle *= 0.95;
- }
- if (intCallChoice == 1)
- {
- priceOfBundle *= 1.15;
- }
- double contractCost = (int) Math.round(priceOfBundle);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement