Assignment brief:
A local toy store wishes you to create an application for parents to enter the details of their children’s Santa list. The Santa list is a database that contains 5 toys, each with a name and a price of format “TOYNAME_PRICE”.
Download full brief here


Download source code here

 //Start of code---------------------
import java.text.DecimalFormat;
import java.util.Calendar;
import java.util.Scanner;
import java.util.regex.Pattern;
import java.util.regex.Matcher;

/* Usage notes:
 * Redistribution, alteration and use of this code with or without
 * modification, are permitted provided that the following conditions are met:
 * In no event shall the copyright owner be liable for any direct, indirect,
 * incidental, special, exemplary, or consequential damages arising in any
 * way out of the use of this software, even if advised of the possibility
 * of such damage.
 */

public class SantaWishList {

  
    public static void main(String[] args) {

        Scanner input = new Scanner(System.in);

        String sname, child1 = null, child2 = null, child3 = null, child4 = null, child5 = null, emailAddress;

        int childTotal, giftReceipt, uniqueToyId = 0;

        String toyDetails = null;

        // • Buy 2 toys, get 10% off the total price
        // • Buy 3 toys or more, get the cheapest toy free

        // Code below is for the surname
        do {
            System.out.print("\nPlease enter your surname to continue\nMinimum 3 charaters (A - Z only): ");

            sname = input.next();
            // sname.toUpperCase().charAt(0);
        } while (sname.length() <= 2 || !sname.matches("[a-zA-Z]+"));

        System.out.println(sname);

        // Code below is for the email address
        System.out.print("\nPlease enter your email address to continue: ");
        emailAddress = input.next();
        while (!emailAddress.matches("[a-zA-Z]*[0-9]*@[a-zA-Z]*.*[a-zA-Z]*")) {

            System.out.print("\nInvalid address!!\nPlease enter a valid email address to continue: ");

            emailAddress = input.next();
        }
        System.out.println(emailAddress);

        // Code below is for amount of children
        System.out.print("\nPlease enter amount of children\nMaximum of 5 per transaction: ");
        childTotal = input.nextInt();

        while (childTotal < 1 || childTotal > 5 ){
            System.out.print("\ndue to the recession, only one toy per child\n");
            System.out.print("\nPlease enter amount of children\nMaximum of 5 per transaction: ");
            childTotal = input.nextInt();
        }

        if (childTotal == 1) {
            System.out.println("\n\tPlease enter childs name");
            child1 = input.next();
            System.out.print("\nPlease select a toy for *" + child1    + "* from the list below\n");
            toyList();
            uniqueToyId = input.nextInt();
            toyDataBase(uniqueToyId);
        } else if (childTotal == 2) {
            System.out.println("\n\tPlease enter the first childs name");
            System.out.print("\nPlease select a toy for " + child1    + " from the list below\n");
            child1 = input.next();
            toyList();
            uniqueToyId = input.nextInt();
            toyDataBase(uniqueToyId);
            System.out.println("\n\tPlease enter the second childs name");
            child2 = input.next();
            System.out.print("\nPlease select a toy for " + child2    + " from the list below\n");
            toyList();
            uniqueToyId = input.nextInt();
            toyDataBase(uniqueToyId);
        } else if (childTotal == 3) {
            System.out.println("\n\tPlease enter the first childs name");
            child1 = input.next();
            System.out.print("\nPlease select a toy for " + child1    + " from the list below\n");
            toyList();
            uniqueToyId = input.nextInt();
            toyDataBase(uniqueToyId);
            System.out.println("\n\tPlease enter the second childs name");
            child2 = input.next();
            System.out.print("\nPlease select a toy for " + child2    + " from the list below\n");
            toyList();
            uniqueToyId = input.nextInt();
            toyDataBase(uniqueToyId);
            System.out.println("\n\tPlease enter the third childs name");
            child3 = input.next();
            System.out.print("\nPlease select a toy for *" + child3    + "* from the list below\n");
            toyList();
            uniqueToyId = input.nextInt();
            toyDataBase(uniqueToyId);
        } else if (childTotal == 4) {
            System.out.println("\n\tPlease enter the first childs name");
            child1 = input.next();
            System.out.print("\nPlease select a toy for *" + child1    + "* from the list below\n");
            toyList();
            uniqueToyId = input.nextInt();
            toyDataBase(uniqueToyId);
            System.out.println("\n\tPlease enter the second childs name");
            child2 = input.next();
            System.out.print("\nPlease select a toy for *" + child2    + "* from the list below\n");
            toyList();
            uniqueToyId = input.nextInt();
            toyDataBase(uniqueToyId);
            System.out.println("\n\tPlease enter the third childs name");
            child3 = input.next();
            System.out.print("\nPlease select a toy for *" + child3    + "* from the list below\n");
            toyList();
            uniqueToyId = input.nextInt();
            toyDataBase(uniqueToyId);
            System.out.println("\n\tPlease enter the fourth childs name");
            child4 = input.next();
            System.out.print("\nPlease select a toy for *" + child4    + "* from the list below\n");
            toyList();
            uniqueToyId = input.nextInt();
            toyDataBase(uniqueToyId);
        } else if (childTotal == 5) {
            System.out.println("\n\tPlease enter the first childs name");
            child1 = input.next();
            System.out.print("\nPlease select a toy for *" + child1    + "* from the list below\n");
            toyList();
            uniqueToyId = input.nextInt();
            toyDataBase(uniqueToyId);
            System.out.println("\n\tPlease enter the second childs name");
            child2 = input.next();
            System.out.print("\nPlease select a toy for *" + child2    + "* from the list below\n");
            toyList();
            uniqueToyId = input.nextInt();
            toyDataBase(uniqueToyId);
            System.out.println("\n\tPlease enter the third childs name");
            child3 = input.next();
            System.out.print("\nPlease select a toy for " + child3 + " from the list below\n");
            toyList();
            uniqueToyId = input.nextInt();
            toyDataBase(uniqueToyId);
            System.out.println("\n\tPlease enter the fourth childs name");
            child4 = input.next();
            System.out.print("\nPlease select a toy for " + child4 + " from the list below\n");
            toyList();
            uniqueToyId = input.nextInt();
            toyDataBase(uniqueToyId);
            System.out.println("\n\tPlease enter the fifth childs name");
            child5 = input.next();
            System.out.print("\nPlease select a toy for " + child5 + " from the list below\n");
            toyList();
            uniqueToyId = input.nextInt();
            toyDataBase(uniqueToyId);
        }

        // Code below is for receipt for one child
        String toy = toyDataBase(uniqueToyId);

        // toy substring
        String type = (toy);
        String toyType;
        toyType = type.substring(0, type.indexOf("_"));
        // System.out.print(type.substring(5,type.indexOf("_")));

        // price substring
        String price = (toy);
        // Double doubleprice = Double.parseDouble(price);
        String price1 = null;
        // Double doubleprice1 = Double.parseDouble(price1);
        price1 = price
                .substring(price.indexOf("_") + 1, price.lastIndexOf(" "));
        // System.out.print(type.substring(5,type.indexOf("_")));

        // String total = (price1 + price1);

        System.out.print("\n\n\t\t   Toy Kingdom\n\t\t  3 Joe Street,\n\t\t   Cork City.\n\n\t");
        date();
        // Receipt printout
        System.out.print("\n\nSANTAS LIST FOR THE *" + sname + "* FAMILY - " + emailAddress + "\n");
        System.out.print("\nCHILD                TOY            PRICE\n");
        if (childTotal == 1) {
        System.out.println(child1+"      " + "      " + type.substring(0, type.indexOf("_"))
                +"     "+ price.substring(price.indexOf("_") + 1,price.lastIndexOf(" ")));}
        else if (childTotal == 2) {
            System.out.println(child1+"      " + "      " + type.substring(0, type.indexOf("_"))
                    +"     "+ price.substring(price.indexOf("_") + 1,price.lastIndexOf(" ")));
            System.out.println(child2+"      " + "      " + type.substring(0, type.indexOf("_"))
                +"     "+ price.substring(price.indexOf("_") + 1,price.lastIndexOf(" ")));}
        else if (childTotal == 3) {
            System.out.println(child1+"      " + "      " + type.substring(0, type.indexOf("_"))
                    +"     "+ price.substring(price.indexOf("_") + 1,price.lastIndexOf(" ")));
            System.out.println(child2+"      " + "      " + type.substring(0, type.indexOf("_"))
                +"     "+ price.substring(price.indexOf("_") + 1,price.lastIndexOf(" ")));
        System.out.println(child3+"      " + "      " + type.substring(0, type.indexOf("_"))
                +"     "+ price.substring(price.indexOf("_") + 1,price.lastIndexOf(" ")));}
        else if (childTotal == 4) {
            System.out.println(child1+"      " + "      " + type.substring(0, type.indexOf("_"))
                    +"     "+ price.substring(price.indexOf("_") + 1,price.lastIndexOf(" ")));
            System.out.println(child2+"      " + "      " + type.substring(0, type.indexOf("_"))
                +"     "+ price.substring(price.indexOf("_") + 1,price.lastIndexOf(" ")));
        System.out.println(child3+"      " + "      " + type.substring(0, type.indexOf("_"))
                +"     "+ price.substring(price.indexOf("_") + 1,price.lastIndexOf(" ")));
        System.out.println(child4+"      " + "      " + type.substring(0, type.indexOf("_"))
                +"     "+ price.substring(price.indexOf("_") + 1,price.lastIndexOf(" ")));}
        else if (childTotal == 5) {
            System.out.println(child1+"      " + "      " + type.substring(0, type.indexOf("_"))
                    +"     "+ price.substring(price.indexOf("_") + 1,price.lastIndexOf(" ")));
            System.out.println(child2+"      " + "      " + type.substring(0, type.indexOf("_"))
                +"     "+ price.substring(price.indexOf("_") + 1,price.lastIndexOf(" ")));
        System.out.println(child3+"      " + "      " + type.substring(0, type.indexOf("_"))
                +"     "+ price.substring(price.indexOf("_") + 1,price.lastIndexOf(" ")));
        System.out.println(child4+"      " + "      " + type.substring(0, type.indexOf("_"))
                +"     "+ price.substring(price.indexOf("_") + 1,price.lastIndexOf(" ")));
        System.out.println(child5+"      " + "      " + type.substring(0, type.indexOf("_"))
                +"     "+ price.substring(price.indexOf("_") + 1,price.lastIndexOf(" ")));}
      
System.out.print("\n\nWould you like a Gift receipt?\nPlease input 1 for Yes or input 2 for No");
      
        giftReceipt = input.nextInt();
      
        while (giftReceipt < 1 || giftReceipt > 2 ){
            System.out.print("\nInvalid input!");
            System.out.print("\nIf you would you like a Gift receipt?\n\nPlease input 1 for Yes or input 2 for No\n\n");
            giftReceipt = input.nextInt();
        }

        if (giftReceipt == 1) {
            System.out.print("\n\n\t    Toy Kingdom\n\t  3 Joe Street,\n\t  Cork City.\n\t");
        System.out.println("\t\n\t **GIFT RECEIPT**\n");  
        if (childTotal == 1) {
        System.out.println("\t|  "+type.substring(0, type.indexOf("_"))+"  |");}
        else if (childTotal == 2) {
            System.out.println("\t|  "+type.substring(0, type.indexOf("_"))+"  |");
        System.out.println("\t|  "+type.substring(0, type.indexOf("_"))+"  |");}
        else if (childTotal == 3) {
            System.out.println("\t|  "+type.substring(0, type.indexOf("_"))+"  |");
        System.out.println("\t|  "+type.substring(0, type.indexOf("_"))+"  |");
        System.out.println("\t|  "+type.substring(0, type.indexOf("_"))+"  |");}
        else if (childTotal == 4) {
            System.out.println("\t|  "+type.substring(0, type.indexOf("_"))+"  |");
        System.out.println("\t|  "+type.substring(0, type.indexOf("_"))+"  |");
        System.out.println("\t|  "+type.substring(0, type.indexOf("_"))+"  |");
        System.out.println("\t|  "+type.substring(0, type.indexOf("_"))+"  |");}
        else if (childTotal == 5) {
            System.out.println("\t|  "+type.substring(0, type.indexOf("_"))+"  |");
        System.out.println("\t|  "+type.substring(0, type.indexOf("_"))+"  |");
        System.out.println("\t|  "+type.substring(0, type.indexOf("_"))+"  |");
        System.out.println("\t|  "+type.substring(0, type.indexOf("_"))+"  |");
        System.out.println("\t|  "+type.substring(0, type.indexOf("_"))+"  |");}
        System.out.println("\n   Thank you for shopping at Toy Kingdom\n       ");
        date();}
        else if (giftReceipt == 2) {
        System.out.println("\nYou have chosen not to receive a gift receipt");
        System.out.println("\nThank you for shopping at Toy Kingdom");}
    }

    // System.out.print("     "+total);

    static String toyDataBase(int uniqueToyId) // Code below is for toy details
    {
        Scanner input = new Scanner(System.in);

        String toyDetails = " ";

        if (uniqueToyId == 1) {
            toyDetails = "Lego Star Wars_39.50 ";
        } else if (uniqueToyId == 2) {
            toyDetails = "3D Eiffel Tower jigsaw_24.99 ";
        } else if (uniqueToyId == 3) {
            toyDetails = "Monopoly Irish Edition_19.50 ";
        } else if (uniqueToyId == 4) {
            toyDetails = "The Irish speaking teddy_17.99 ";
        } else if (uniqueToyId == 5) {
            toyDetails = "Toy Story Laptop_34.95 ";
        }

        return toyDetails;
    }

    public static void toyList() // Code below is for toy list
    {

        System.out.print("\n\t\t Toy List\n");
        System.out.print("______________________________________________\n");
        System.out.print("\n  1.Lego Star Wars\t\t\u20AC39.50");
        System.out.print("\n  2.3D Eiffel Tower jigsaw\t\u20AC24.99");
        System.out.print("\n  3.Monopoly Irish Edition\t\u20AC19.50");
        System.out.print("\n  4.The Irish speaking teddy\t\u20AC17.99");
        System.out.print("\n  5.Toy Story Laptop\t\t\u20AC34.95");
        System.out.print("\n______________________________________________\n");
    }
  
    public static void date()
    {
    DecimalFormat fmt = new DecimalFormat("00");

           Calendar now = Calendar.getInstance();

           int hour = now.get(Calendar.HOUR_OF_DAY);

           int minute = now.get(Calendar.MINUTE);

           int month = now.get(Calendar.MONTH)+ 1;

           int day = now.get(Calendar.DAY_OF_MONTH);

           int year = now.get(Calendar.YEAR);
                    
           System.out.print("       "+hour+":" + minute );
             
           System.out.print(" " + day + " ");
         
           switch (month)

           {
               case 1:
                   System.out.print("Jan");
                   break;

               case 2:
                   System.out.print("Feb");
                   break;

               case 3:
                   System.out.print("Mar");
                   break;

               case 4:
                   System.out.print("Apr");
                   break;

               case 5:
                   System.out.print("May");
                   break;

               case 6:
                   System.out.print("June");
                   break;

               case 7:
                   System.out.print("July");
                   break;

               case 8:
                   System.out.print("Aug");
                   break;

               case 9:
                   System.out.print("Sept");
                   break;

               case 10:
                   System.out.print("Oct");
                   break;

               case 11:
                   System.out.print("Nov");
                   break;

               case 12:
                   System.out.print("Dec");
          }
           System.out.print(" "+year);
}
}//End of code---------------------

Assignment brief:
It’s coming up to pantomime season and CIT are planning on staging their first ever pantomime in the Rory Gallagher theatre. You have been asked to design and develop a Java application for box office staff to help them manage the bookings for the theatre.
The program should be generic so that it can, with minimal modification, work for any size theatre with a rectangular arrangement of seats.
Download full brief here

Download source code here

// Start of code---------------------
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.Scanner;

/* Usage notes:
 * Redistribution, alteration and use of this code with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * In no event shall the copyright owner be liable for any direct, indirect,
 * incidental, special, exemplary, or consequential damages arising in any
 * way out of the use of this software, even if advised of the possibility
 * of such damage.
 */

public class TicketSystem {



    public static void main(String[] args) {
       

        NumberFormat numberFormat = new DecimalFormat("\u20AC#,##0.00");

        Scanner input = new Scanner(System.in);

        final double costPremium = 10.00;
        final double costRegular = 7.50;
        final double costEconomy = 5.00;

        final int rowsPrem = 2;
        final int rowsReg = 6;
        final int rowsEcon = 2;
        final int seatColumns = 15;

        int premNumTotal = 0, regNumTotal = 0, econNumTotal = 0, premCancel = 0, regCancel = 0, econCancel = 0;

        int buySeats = 0, cancel = 0, yes, choice = 0;

        // Theatre banner
        printStars();
        System.out.println("************** Pantomine ***************");
        printStars();
        System.out.println("****** The Rory Galagher Theatre *******");
        printStars();

        // Seat symbol legend
        System.out.println("\n\t\t A ‘#’ symbol represents an available seat ");
        System.out.println("\n\t\t A ‘P’ represents a booked premium seat. ");
        System.out.println("\n\t\t An ‘R’ represents a booked regular seat.");
        System.out.println("\n\t\t An ‘E’ represents a booked economy seat. ");

        // Stage layout
        System.out
                .println("\n\t     |                     STAGE                     |");
        System.out
                .println("\t     |_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _|\n");

        // Seat layout
        printSeats();

        // Ticket purchase section
        do {
            System.out
                    .println("\n\t\tWhat type of seat do you want to buy tickets for?");

            seatPriceMenu();
            // while(! input.hasNextInt())

            choice = input.nextInt();
            while (choice < 1 || choice > 3) {
                System.out
                        .println("\n\t\tIncorrect input!!\n\tWhat type of seat do you want to buy tickets for?");
                seatPriceMenu();
                choice = input.nextInt();
            }
            switch (choice) {
            case 1:
                System.out
                        .println("\n\t\tYou would like to book some Premium Seats - "
                                + numberFormat.format(costPremium) + " each.");
                System.out
                        .print("\n\t\tHow many tickets do you want to buy : ");
                buySeats = input.nextInt();

                if (buySeats > rowsPrem * seatColumns - premNumTotal) {
                    System.out.print("You cannot book " + buySeats
                            + " tickets as there are only "
                            + (rowsPrem * seatColumns - premNumTotal)
                            + " seats available.");
                }
                break;

            case 2:
                System.out
                        .println("\t\tYou would like to book some Regular Seats - "
                                + numberFormat.format(costRegular) + " each.");
                System.out
                        .print("\n\t\tHow many tickets do you want to buy : ");
                buySeats = input.nextInt();

                if (buySeats > rowsReg * seatColumns - regNumTotal) {
                    System.out.print("You cannot book " + buySeats
                            + " tickets as there are only "
                            + (rowsReg * seatColumns - regNumTotal)
                            + " seats available.");
                }
                break;

            case 3:
                System.out
                        .println("\t\tYou would like to book some Economy Seats - "
                                + numberFormat.format(costEconomy) + " each.");
                System.out
                        .print("\n\t\tHow many tickets do you want to buy : ");
                buySeats = input.nextInt();

                if (buySeats > rowsEcon * seatColumns - econNumTotal) {
                    System.out.print("You cannot book " + buySeats
                            + " tickets as there are only "
                            + (rowsEcon * seatColumns - econNumTotal)
                            + " seats available.");
                }
                break;

            default:

                break;
            }

            if (choice == 1) {
                if (buySeats <= (rowsPrem * seatColumns - premNumTotal)) {
                    premNumTotal += buySeats;
                    System.out.print("\n\t\tYou want to buy " + premNumTotal
                            + " Seats, ");
                }
                System.out.print("total cost : "
                        + numberFormat.format(costPremium * premNumTotal)
                        + "\n");

            }
            if (choice == 2) {
                if (buySeats <= (rowsReg * seatColumns - regNumTotal)) {
                    regNumTotal += buySeats;
                    System.out.print("\n\t\tYou want to buy " + regNumTotal
                            + " Seats, ");
                }
                System.out
                        .print("total cost : "
                                + numberFormat
                                        .format(costRegular * regNumTotal)
                                + "\n");

            }
            if (choice == 3) {
                if (buySeats <= (rowsEcon * seatColumns - econNumTotal)) {
                    econNumTotal += buySeats;
                    System.out.print("\n\t\tYou want to buy " + econNumTotal                            + " Seats, ");
                }
                System.out.print("total cost : "
                        + numberFormat.format(costEconomy * econNumTotal));

            }
            System.out.print("\t\t");
            underline();
            System.out
                    .print("\n\n\t\tWould you like to book more tickets ? Enter 1 for yes or 2 for no : ");
            yes = input.nextInt();

        } while (yes == 1);

        // Ticket amount and cost total
        int numTotal = premNumTotal + regNumTotal + econNumTotal - premCancel
                - regCancel - econCancel;

        double costTotal = costPremium * premNumTotal + costRegular
                * regNumTotal + costEconomy * econNumTotal - costPremium
                * premCancel - costRegular * regCancel - costEconomy
                * econCancel;

        System.out
                .println("\n\n\t\tYou have selected not to book more tickets");
        System.out.println("\n\t\tYou provisionally booked " + numTotal
                + " tickets");

        System.out.println("\t\tYour Subtotal is : "
                + numberFormat.format(costTotal));
        System.out.print("\t\t");
        dottedUnderline();

        // Ticket cancelling section

        System.out
                .print("\n\n\t\tWould you like to cancel tickets ? Enter 1 for yes or 2 for no : ");
        yes = input.nextInt();

        while (yes < 1 || yes > 2) {
            System.out
                    .println("\n\t\tIncorrect input!!\n\t\tWould you like to cancel tickets ? Enter 1 for yes or 2 for no : ");
            yes = input.nextInt();
        }

        while (yes == 1) {

            System.out.println("\n\t\tWhat ticket would you like to cancel?");

            seatPriceMenu();

            choice = input.nextInt();
            switch (choice) {
            case 1:
                System.out
                        .println("\n\t\tYou would like to cancel some Premium Seats - "
                                + numberFormat.format(costPremium) + " each.");
                System.out
                        .print("\n\t\tHow many tickets do you want to cancel : ");
                cancel = input.nextInt();

                if (cancel > premNumTotal) {
                    System.out.print("You cannot cancel " + cancel
                            + " tickets as you only have " + premNumTotal
                            + " tickets purchased.");
                }
                break;

            case 2:
                System.out
                        .println("\t\tYou would like to cancel some Regular Seats - "
                                + numberFormat.format(costRegular) + " each.");
                System.out
                        .print("\n\t\tHow many tickets do you want to cancel : ");
                cancel = input.nextInt();

                if (cancel > regNumTotal) {
                    System.out.print("You cannot cancel " + cancel
                            + " tickets as you only have " + regNumTotal
                            + " tickets purchased.");
                }
                break;

            case 3:
                System.out
                        .println("\t\tYou would like to cancel some Economy Seats - "
                                + numberFormat.format(costEconomy) + " each.");
                System.out
                        .print("\n\t\tHow many tickets do you want to cancel : ");
                cancel = input.nextInt();

                if (cancel > econNumTotal) {
                    System.out.print("You cannot cancel " + cancel
                            + " tickets as you only have " + econNumTotal
                            + " tickets purchased.");
                }
                break;

            default:

                break;
            }

            if (choice == 1) {
                if (cancel <= premNumTotal) {
                    premCancel += cancel;
                    System.out.print("\n\t\tYou want to cancel " + premCancel
                            + " Seats, ");
                }
                System.out.print("total cost canceled : "
                        + numberFormat.format(costPremium * premCancel) + "\n");
                // premNumTotal-=cancel;
            }
            if (choice == 2) {
                if (cancel <= regNumTotal) {
                    regCancel += cancel;
                    System.out.print("\n\t\tYou want to cancel " + regCancel
                            + " Seats, ");
                }
                System.out.println("total cost canceled : "
                        + numberFormat.format(costRegular * regCancel) + "\n");

            }
            if (choice == 3) {
                if (cancel <= econNumTotal) {
                    econCancel += cancel;
                    System.out.print("\n\t\tYou want to cancel " + econCancel
                            + " Seats, ");
                }
                System.out.println("total cost canceled : "
                        + numberFormat.format(costEconomy * econCancel) + "\n");

            }
            System.out.print("\t\t");
            underline();
            System.out
                    .print("\n\n\t\tWould you like to cancel more tickets ? Enter 1 for yes or 2 for no : ");
            yes = input.nextInt();
        }
        input.close();
        // Ticket amount and cost total
        System.out
                .println("\n\t\tYou booked " + numTotal + " tickets in total");

        System.out.println("\t\tYour total cost is : "
                + numberFormat.format(costTotal));
        System.out.print("\n\t\t\t     Selected seat layout\n\n");
        printSeats();
        System.out.print("\n\t\t");
       
        dottedUnderline();

        // Purchase reports menus
        System.out.println("\n\n\t\tSales Summary");
        System.out.print("\t\t");
        reportUnderline();
        System.out.println("\n\t\tNumber of premium tickets sold: "
                + (premNumTotal - premCancel));
        System.out.println("\t\tNumber of regular tickets sold: "
                + (regNumTotal - regCancel));
        System.out.println("\t\tNumber of economy tickets sold: "
                + (econNumTotal - econCancel));
        System.out.println("\t\tTotal value of Ticket Sales: "
                + numberFormat.format(costTotal));

        System.out.println("\n\t\tSales Bar Chart");
        System.out.print("\t\t");
        reportUnderline();
        System.out.print("\n\t\tNumber of premium tickets sold: ");
        for (int premBar = 1; premBar <= premNumTotal - premCancel; premBar++) {
            System.out.print("|");
        }
        System.out.print("\n");
        System.out.print("\t\tNumber of regular tickets sold: ");

        for (int regBar = 1; regBar <= regNumTotal - regCancel; regBar++) {
            System.out.print("|");
        }
        System.out.print("\n");
        System.out.print("\t\tNumber of economy tickets sold: ");

        for (int econBar = 1; econBar <= econNumTotal - econCancel; econBar++) {
            System.out.print("|");
        }
        System.out.println("\n\n\t\tTicket Availability");
        System.out.print("\t\t");
        reportUnderline();
        System.out.println("\n\t\tPremium tickets: "
                + (rowsPrem * seatColumns - (premNumTotal - premCancel)));
        System.out.println("\t\tRegular tickets: "
                + (rowsReg * seatColumns - (regNumTotal - regCancel)));
        System.out.println("\t\tEconomy tickets: "
                + (rowsEcon * seatColumns - (econNumTotal - econCancel)));
    }
   

    // method for seat menu and prices
    public static void seatPriceMenu() {
        NumberFormat numberFormat = new DecimalFormat("\u20AC#0.00");

        final double costPremium = 10.00;
        final double costRegular = 7.50;
        final double costEconomy = 5.00;

        System.out.println("\n\t\t[1] Premium Seats "
                + numberFormat.format(costPremium));
        System.out.println("\t\t[2] Regular Seats "
                + numberFormat.format(costRegular));
        System.out.println("\t\t[3] Economy Seats "
                + numberFormat.format(costEconomy));
        System.out.print("\n\t\tEnter a value between 1, 2, or 3 :  ");
    }

    // Top of banner
    public static void printStars() {
        int stars, lines;

        System.out.print("\t\t  ");
        for (lines = 1; lines <= 1; lines++) {
            for (stars = 1; stars <= 40; stars++)

                System.out.print("~");
            System.out.println();
            System.out.print("\t\t  ");
        }

    }

    public static void underline() {
        System.out.print("\n\t\t");
        for (int underLine = 0; underLine <= 68; underLine++) {
            System.out.print("_");
        }
    }

    public static void dottedUnderline() {
        for (int dottedUnderLine = 0; dottedUnderLine <= 34; dottedUnderLine++) {
            System.out.print("_ ");
        }
    }

    public static void reportUnderline() {
        for (int dottedUnderLine = 0; dottedUnderLine <= 51; dottedUnderLine++) {
            System.out.print("=");
        }
    }
   
    // Method for seat layout
    public static void printSeats() {

        final int rowsPrem = 2;
        final int rowsReg = 6;
        final int rowsEcon = 2;
        final int seatColumns = 15;
        int premSeats;
        int regSeats;
        int econSeats;
        int premColumn;
        int regColumn;
        int econColumn;

        for (premSeats = 0; premSeats < rowsPrem; premSeats++) {
            System.out.print("\t\t\t");
            for (premColumn = 0; premColumn < seatColumns; premColumn++) {
                System.out.print(" #");
            }
            System.out.println();
        }

        {
            for (regSeats = 0; regSeats < rowsReg; regSeats++) {
                System.out.print("\t\t\t");
                for (regColumn = 0; regColumn < seatColumns; regColumn++) {
                    System.out.print(" #");
                }
                System.out.println();
            }

            {
                for (econSeats = 0; econSeats < rowsEcon; econSeats++) {
                    System.out.print("\t\t\t");
                    for (econColumn = 0; econColumn < seatColumns; econColumn++) {
                        System.out.print(" #");
                    }
                    System.out.println();
                }
                System.out.print("\t\t\t");

            }
           
        }
       
    }
} // End of code---------------------

Assignment brief:
Working by yourself, you are to create “Lotto QuickPick” software that will store 6 randomly generated numbers ranging from 1 to 45 for use in the Irish lotto and save the results to a file.
Download full brief here


Download source code here

//Start of code---------------------
package lottoquickpick;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintStream;
import java.util.Scanner;

/* Usage notes:
 * Redistribution, alteration and use of this code with or without
 * modification, are permitted provided that the following conditions are met:
 * In no event shall the copyright owner be liable for any direct, indirect,
 * incidental, special, exemplary, or consequential damages arising in any
 * way out of the use of this software, even if advised of the possibility
 * of such damage.
 */

public class LottoQuickPick {

    public static void main(String[] args) throws FileNotFoundException {
        Scanner input = new Scanner(System.in);

        String name, firstName, mobile, initials, mobileDigits;

        final String nameError = "Invalid name input!!\nPlease input A to Z characters only to continue: ";
        final String mobileError = "Invalid mobile number!!\nPlease input 0 to 9 digits only to continue: ";
        final String lineAmountError = "Invalid digit!!\nPlease input 0 to 9 digits only to continue: ";
        int lineAmount = 0;

        // Start of output to console-------------------
        welcomeHeader();

        // Code below is for the name input-------------------
        System.out
                .print("\nPlease enter your full name to continue(A - Z only) ie. Joe Soap: ");
        name = input.nextLine();

        while (name.length() <= 3 || !name.matches("[a-z A-Z]+")) {
            System.out.print(nameError);
            name = input.nextLine();
        }
        //name.length();
        // -------------------------------------------------

        // Code below is for the mobile #-------------------
        System.out
                .print("Please enter your Mobile Number (0-9 digits only (ie. 0871234567): ");
        mobile = input.next();

        while (mobile.length() != 10 || !mobile.matches("[0-9]+")) {
            System.out.print(mobileError);
            mobile = input.next();
        }
        // -------------------------------------------------

        // All substring and indexOf code-------------------

        // last four digits of mobile #
        mobileDigits = (mobile.substring(6, 10));
        // capital letters for full name
        String nameCaps = Character.toUpperCase(name.charAt(0))
                + name.substring(1);
        // split first name for the end of output file message
        firstName = nameCaps.substring(0, name.indexOf(" "));
        // initials code
        initials = nameCaps.substring(0, 1)
                + nameCaps.substring(name.lastIndexOf(" ") + 1).substring(0, 1)
                        .toUpperCase();
        // -------------------------------------------------
       
        // code below is for line amount input--------------
        System.out.print("\nHow many lotto lines would you like? ");

        while (!input.hasNextInt()) {
            System.out.print(lineAmountError);
            input.next();
        }
        lineAmount = input.nextInt();
        // -------------------------------------------------

        // file name information for console
        String fileName = "\nC:/Documents and Settings/Lesley/Desktop/lotto_" + initials + "_" + mobileDigits + ".txt";

        System.out.print("\nYour lotto numbers are:");

        // Start of output file information - This file will save to the package
        // folder-------------------
        PrintStream out = new PrintStream(new File("C:/Documents and Settings/Lesley/Desktop/lotto_" + initials + "_" + mobileDigits + ".txt"));

        out.println("Name: " + nameCaps);
        out.println("Contact: " + mobile);
        out.println("\n");
        out.print("\nYour lotto numbers are:");

        // Code for lines-------------------
        int lottoLines = 0;
        @SuppressWarnings("unused")
        int sum = 0;

        for (int line = 0; line < lineAmount; line++) {
            // This nested section will allow for lotto #'s to line up if the
            // lotto line input is a double figure ie: 10 or 12
            if (lineAmount > 9) {
                if (line < 9) {
                    System.out.print("\nLine " + (line + 1) + ":  ");
                    out.println("\n");
                    out.print("Line " + (line + 1) + ":  ");
                } else {
                    System.out.print("\nLine " + (line + 1) + ": ");
                    out.println("\n");
                    out.print("Line " + (line + 1) + ": ");
                }
            } else {
                System.out.print("\nLine " + (line + 1) + ": ");
                out.println("\n");
                out.print("Line " + (line + 1) + ": ");
            }
            sum += lottoLines;
            {
                // read & store each lotto #'s-------------------
                String results = "";
                int aNumber, numberOfNumbers = 6;
                int counter;

                for (counter = 1; counter <= numberOfNumbers; counter++) {
                    aNumber = (int) ((Math.random() * 45) + 1);
                    if (aNumber >= 10) {
                        results += aNumber + " ";
                    } else {
                        results += " " + aNumber + " ";
                    }
                }

                System.out.print(results);
                out.print(results);
            }
        }
        // -------------------------------------------------

        // file name information console print--------------
        System.out.print("\n\nYour Lotto Numbers have been saved to:"
                + fileName);
        out.println("\n");
        out.println("\n");
        out.println("Thank you for playing. Best of luck " + firstName + ".");
        // -------------------------------------------------
        out.close();
        input.close();
    }

    // method for welcome header
    public static void welcomeHeader() {
        System.out.println("\nWELCOME TO LOTTO QUICKPICK");
    }

}//End of code---------------------
Assignment brief:
The Lotto QuickPick software application that you wrote previously (https://www.dropbox.com/sh/8eb6sg5oad0lg89/3DRtDl6uuz) has been well received and the client is looking to enhance the functionality. They want to add options such as lotto game selection and a checkout screen showing the cost of the game based on how many lines were purchased.
Download full brief here

Download source code here

// Start of code---------------------
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintStream;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.Random;
import java.util.Scanner;

/* Usage notes:
 * Redistribution, alteration and use of this code with or without
 * modification, are permitted provided that the following conditions are met:
 * In no event shall the copyright owner be liable for any direct, indirect,
 * incidental, special, exemplary, or consequential damages arising in any
 * way out of the use of this software, even if advised of the possibility
 * of such damage.
 */

public class DatabaseLottoQuickPick {

    public static void main(String[] args) throws FileNotFoundException {

        Scanner kb = new Scanner(System.in);
        // It is assumed that the dataBase text document will be read from the
        // lotto quick pick folder name above (ie: DatabaseLottoQuickPick)
        final String dataBaseFileName = "database_lotto.txt";
        final String nameError = "Invalid name input!!\nPlease input A to Z characters only and at least one space to continue - ie. Joe Soap: ";
        final String mobileError = "Invalid mobile number!!\nPlease input 0 to 9 digits only to continue (10 digits please - ie. 0871234567): ";

        final int lottoNumbersPerLine = 6;

        boolean menuError = false;
        boolean lineError = false;

        String name, firstName, mobile, initials, mobileDigits, writeToFileName;
        String lottoLines = "";
        String options = "";
        String finalOption = "";
        String menuSelection = "";
        String lAmount = "";

        int lineAmount = 0;
        int randomNumber = 0;
        int gameOption = 0;

        File dataBase = new File(dataBaseFileName);
        dataBase = new File(dataBaseFileName);
        Scanner input = exists(dataBase, dataBaseFileName);

        final String gameSelectionError = "Invalid input!!\nPlease input digits 1 to "
                + fileRowCount(dataBaseFileName)
                + " for game options or Q to quit lotto quickpick: ";

        NumberFormat numberFormat = new DecimalFormat("\u20AC##.00");

        String[][] gameArray = new String[fileRowCount(dataBaseFileName)][3];

        readFileToArray(input, dataBase, kb, gameArray);

        System.out.print("WELCOME TO LOTTO QUICKPICK\n");

        // Code below is for the name input-------------------
        System.out
                .print("\nPlease enter your full name to continue(A - Z characters only and must contain at least one space - ie. Joe Soap: ");

        name = kb.nextLine();

        while (name.length() <= 3
                || !name.matches("[a-zA-z]+([ '-][a-zA-Z]+)*")
                || !name.contains(" ")) {
            System.out.print(nameError);
            name = kb.nextLine();
        }
        // -------------------------------------------------

        // Code below is for the mobile #-------------------
        System.out
                .print("Please enter your 10 digit Mobile Number (0-9 digits only - ie. 0871234567): ");
        mobile = kb.next();

        while (mobile.length() != 10 || !mobile.matches("[0-9]+")) {
            System.out.print(mobileError);
            mobile = kb.next();
        }
        // -------------------------------------------------

        // All substring and indexOf code-------------------

        // last four digits of mobile #
        mobileDigits = (mobile.substring(6, 10));

        // capital letters for full name
        String nameCaps = Character.toUpperCase(name.charAt(0))
                + name.substring(1, name.indexOf(" "))
                + " "
                + name.substring(name.indexOf(" ") + 1).substring(0, 1)
                        .toUpperCase() + name.substring(name.indexOf(" ") + 2);
        // split first name for the end of output file message

        firstName = nameCaps.substring(0, name.indexOf(" "));
        // initials code
        initials = nameCaps.substring(0, 1)
                + nameCaps.substring(name.lastIndexOf(" ") + 1).substring(0, 1)
                        .toUpperCase();
        // -------------------------------------------------

        // file name information for console
        writeToFileName = "lotto_" + initials + "_" + mobileDigits + ".txt";

        System.out.print("\nYour full name: " + nameCaps);
        System.out.print("\nYour Contact number: " + mobile);
        do {
            do {
                menu(gameArray, numberFormat, dataBaseFileName);
                System.out.println();

                do {
                    menuError = false;

                    menuSelection = kb.next();

                    if (menuSelection.matches("Q")
                            || menuSelection.matches("q")) {
                        System.out
                                .print("\nYou have chosen to quit!\nHope to see you again "
                                        + nameCaps + ".");
                        System.exit(0);
                    } else if (menuSelection.matches("[1-9]+")) {
                        if (Integer.parseInt(menuSelection) < fileRowCount(dataBaseFileName) + 1) {
                            gameOption = Integer.parseInt(menuSelection);
                        } else if (Integer.parseInt(menuSelection) > fileRowCount(dataBaseFileName)) {
                            menuError = true;
                            System.out.print(gameSelectionError);
                        }
                    } else {
                        menuError = true;
                        System.out.print(gameSelectionError);
                    }
                } while (menuError);

                System.out.println("\nWelcome " + firstName);
                do {
                    System.out.print("\nYou have chosen to play ["
                            + gameOption+ "] "+ (gameArray[gameOption - 1][0])+ ".\n"
                            + gameArray[gameOption - 1][0]+ " costs "+ numberFormat.format(Double.parseDouble(gameArray[gameOption - 1][2]))
                            + " to play and has a minimum purchase of "
                            + gameArray[gameOption - 1][1] + " line(s)."
                            + "\nHow many " + gameArray[gameOption - 1][0]
                            + " would you like?");
                    lAmount = kb.next();
                    lineAmount = gameLines(kb, lAmount, gameArray, gameOption,
                            lineAmount, dataBaseFileName, lineError);

                    System.out.println("\nThe total cost to play "
                            + gameArray[gameOption - 1][0]
                            + " will be "
                            + numberFormat.format(Double
                                    .parseDouble(gameArray[gameOption - 1][2])
                                    * lineAmount));

                    System.out
                            .println("\nWould you like to continue?\nPlease choose one of the following:"
                                    + "\nY for Yes\nN for No\nQ for Quit ");

                    do {
                        options = kb.next();
                        menuError = false;
                        if (options.matches("[a-z A-Z]+")) {
                            if (options.equals("Y") || options.equals("y")
                                    || options.equals("N")
                                    || options.equals("n")
                                    || options.equals("Q")
                                    || options.equals("q")) {
                                System.out
                                        .print("\nYou have chosen to continue.\n\nName: "
                                                + nameCaps
                                                + "\nContact number: "
                                                + mobile
                                                + "\n");
                                // options=options;
                            } else {
                                System.out
                                        .print("\nInput Error!\nThis is a yes or no question.\n"
                                                + "If you would like to play another game please input Y for Yes, N for No or Q for Quit\nY for Yes\nN for No\nQ for Quit ");
                                menuError = true;
                            }
                        } else if (options.matches("[0-9]+")) {
                            System.out
                                    .print("\nInput Error!\nThis is a yes or no question.\n"
                                            + "If you would like to play another game please input Y for Yes, N for No or Q for Quit\nY for Yes\nN for No\nQ for Quit ");
                            menuError = true;
                        }
                    } while (menuError);

                    if (options.equals("Y") || options.equals("y")) {

                        lottoLines = "\nYour " + (gameArray[gameOption - 1][0])
                                + " Numbers are:\n";
                        // Prints Line and # for each individual line
                        for (int line1 = 1; line1 <= lineAmount; line1++) {
                            if (lineAmount > 9) {
                                if (line1 <= 9) {
                                    lottoLines += "Line " + line1 + ":  ";
                                } else {
                                    lottoLines += "Line " + line1 + ": ";
                                }
                            } else {
                                lottoLines += "Line " + line1 + ": ";
                            }

                            lottoLines += numberGenerator(lottoLines,
                                    randomNumber, lottoNumbersPerLine);
                        }
                        System.out.print(lottoLines);
                        // file name information console print--------------
                        System.out.print("\nYour "
                                + (gameArray[gameOption - 1][0])
                                + " have been saved to:\n" + writeToFileName);

                        printToFile(name, mobile, gameArray, gameOption,
                                lineAmount, nameCaps, firstName,
                                writeToFileName, initials, mobileDigits,
                                lottoLines, numberFormat);

                        System.out
                                .print("\n\nThe total cost: "
                                        + numberFormat.format(Double
                                                .parseDouble(gameArray[gameOption - 1][2])
                                                * lineAmount)
                                        + " Thank you for playing " + firstName
                                        + ".\n\n");
                    }
                } while (options.equals("N") || options.equals("n"));

            } while (options.equals("Q") || options.equals("q"));

            finalOption = finalLoopOption(kb, finalOption, firstName, menuError);

        } while (finalOption.equals("Y") || finalOption.equals("y"));

        kb.close();
        input.close();
        System.exit(0);
    }

    @SuppressWarnings("resource")
    public static void printToFile(String name, String mobile,
            String[][] gameArray, int gameOption, int lineAmount,
            String nameCaps, String firstName, String writeToFileName,
            String initials, String mobileDigits, String lottoLines,
            NumberFormat numberFormat) throws FileNotFoundException {

        PrintStream out = new PrintStream(new File(writeToFileName));

        out.println("Name: " + nameCaps);
        out.println("Contact: " + mobile);
        out.println(lottoLines);
        out.println("\nThe total cost: "
                + numberFormat.format(Double
                        .parseDouble(gameArray[gameOption - 1][2]) * lineAmount)
                + " Thank you for playing " + firstName + ".");
    }

    public static int gameLines(Scanner kb, String lAmount,
            String[][] gameArray, int gameOption, int lineAmount,
            final String dataBaseFileName, boolean lineError)
            throws NumberFormatException, FileNotFoundException {

        final String gameLineError = "\nInput Error!!\nPlease use numeric digits only - Take note of minimum line requirement below.\n"
                + gameArray[gameOption - 1][0]
                + " has a minimum purchase of "
                + gameArray[gameOption - 1][1]
                + " line(s)."
                + "\nHow many "
                + gameArray[gameOption - 1][0] + " would you like?";

        for (int line = 1; line <= fileRowCount(dataBaseFileName); line++) {
            if (gameOption == line)

                do {
                    lineError = false;

                    if (lAmount.matches("[0-9]+")
                            && Integer.parseInt(lAmount) >= Integer
                                    .parseInt(gameArray[gameOption - 1][1])) {
                        lineAmount = Integer.parseInt(lAmount);
                    } else {
                        while (!lAmount.matches("[0-9]+")
                                || Integer.parseInt(lAmount) < Integer
                                        .parseInt(gameArray[gameOption - 1][1])
                                || lAmount.matches("[a-z A-Z]+")) {

                            System.out.print(gameLineError);

                            lineError = true;
                            lAmount = kb.next();
                        }

                    }
                } while (lineError);
        }
        return lineAmount;
    }

    public static String numberGenerator(String lottoLines, int randomNumber,
            final int lottoNumbersPerLine) {
        // Generates 6 random digits for each line
        String lottoLines2 = "";
        for (int counter = 1; counter <= lottoNumbersPerLine; counter++) {
            Random rand = new Random();
            randomNumber = rand.nextInt(45) + 1;
            // Creates a space before a single digit so
            // it'll line up with double digit
            if (randomNumber < 10) {
                lottoLines2 += " ";

            }
            lottoLines2 += randomNumber + " ";
        }
        lottoLines2 += "\n";
        return lottoLines2;
    }

    public static void menu(String[][] gameArray, NumberFormat numberFormat,
            final String dataBaseFileName) throws FileNotFoundException {
        final int menuNumber = fileRowCount(dataBaseFileName) + 1;

        System.out.print("\n\nLOTTO GAME RULES:\n");

        for (int row = 0; row < menuNumber - 1; row++) {

            System.out
                    .print(gameArray[row][0]+ " require at least "+ gameArray[row][1]+ " line(s) to be purchased @ "
                            + numberFormat.format(Double.parseDouble(gameArray[row][2]))+ " per line.\n");

        }
        System.out.print("\nPlease select a game to play!");
        System.out.println();

        for (int number = 1; number < menuNumber; number++) {
            System.out.print("\n[" + number + "] ");
            System.out.print(gameArray[number - 1][0]);
        }
        System.out.print("\n[Q] Quit");
    }

    public static Scanner exists(File dataBase, final String dataBaseFileName)
            throws FileNotFoundException {

        while (!dataBase.canRead()) {
            System.out
                    .println("File not found!!\nPlease check your file directory path and run again!");
            System.exit(0);
            //dataBase = new File(dataBaseFileName);
        } // now we know that dataBase is a file that can be read
        return new Scanner(dataBase);
    }

    public static String finalLoopOption(Scanner kb, String finalOption,
            String firstName, boolean menuError) {

        String finalQuestion = "Please choose one of the following:\nY for Yes\nN for No";

        System.out.print("Would you like to play another game?\n"
                + finalQuestion);
        menuError = false;
        do {
            menuError = false;
            finalOption = kb.next();

            if (finalOption.equals("N") || finalOption.equals("n")) {
                System.out.print("\nThanks for playing " + firstName
                        + " , Good Bye.");
            } else if (finalOption.equals("Y") || finalOption.equals("y")) {
                // finalOption = finalOption;
            } else {
                System.out
                        .print("\nInput Error!\nThis is a yes or no question.\n"
                                + "If you would like to play another game please input Y for yes or input N for quit\n"
                                + finalQuestion);
                menuError = true;
            }
        } while (menuError);

        return finalOption;

    }

    @SuppressWarnings("resource")
    public static int fileRowCount(final String dataBaseFileName)
            throws FileNotFoundException {

        Scanner countLines = new Scanner(new File(dataBaseFileName));
        int count = 0;
        while (countLines.hasNextLine()) {

            String line = countLines.nextLine();
            @SuppressWarnings("unused")
            Scanner lineScan = new Scanner(line);

            count++;
        }
        return count;
    }

    private static void readFileToArray(Scanner input, File dataBase,
            Scanner kb, String[][] gameArray) {

        int row = 0;
        int column = 0;
        while (input.hasNextLine()) {

            String line = input.nextLine();
            @SuppressWarnings("resource")
            Scanner lineScan = new Scanner(line);

            String game = lineScan.next() + " " + lineScan.next();
            gameArray[row][column] = game;// Lotto name

            int lineLimit = lineScan.nextInt();
            gameArray[row][column + 1] = Integer.toString(lineLimit);

            Double price = lineScan.nextDouble();
            gameArray[row][column + 2] = price.toString();
            row++;
        }
    }
}//End of code---------------------

Test run of program
Test run of program