ITECH1000 : Programming - Design Assignment - Assessment Answer

December 28, 2018
Author : Sara Lanning

Solution Code: 1ABCF

Question: Programming Case Study

This assignment is related to ” Marketing Case Study” and experts at My Assignment Services AU successfully delivered HD quality work within the given deadline.

Programming Assignment

Case Scenario/ Task

Section 1: Design Documentation

  1. Requirements:

  • The system will be implemented as simple nested menu driven program with do-while loop until the user exits and nested switch() statement.

The main menu will be,-

  1. Purchase Tickets.
  2. View Ticket Sales.
  3. Exit System.

When the user selects option 1, then another sub-menu will display as,-

  1. Adult Tickets.
  2. Child Tickets.
  3. Finalize Order.
  4. Cancel Order.

  • After entering option 1 and option 2 in sub-menu, the system prompts for entering Number of Tickets.
  • User can cancel order by selecting option 4 in the sub-menu. After choosing the option 4 in sub-menu, the main menu will re-display.
  • If the User selects option 3 in sub-menu, the total order number for Adult tickets and Child tickets along with total cost for that particular order will display. Then, back to the main menu.
  • In the main menu, user can select the option 1 again to give another order.
  • When the user selects option 2 in the main menu, the total income from all orders including number of Adult tickets and child tickets are shown.
  • If the user selects option 3 in the main menu, the application exits.
  • If the user selects any number other than options then main menu and sub-menu will display again.

 

  • The heading will be displayed as per requirements. In the advanced functionality, the date difference between current system date and 1st October, 2016 will show to implement the countdown of the Games.

 

  1. Pseudo-code or Algorithm:

Step 1: The main() function calls two sub functions like disp_heading() and menu_disp() to implement the modularization feature.

Step 2: In the disp_heading() function, the heading is displayed with for loop ( for * and space) as well as the GregorianCalendar class is used to find the difference between current system date and 1st October,2016. An object is created under GregorianCalendar class and sets the festival (Olympic games) date as 1st October, 2016. Its millisecond is calculated as p.getTime() . The current system date’s time is calculated as millisecond and stored into currentTime. The diff is the difference between current time and p.getTime() in millisecond. Then the millisecond is converted into number of days and stored into res.

 

Step 3: In the menu_disp() function, using do-while() loop, the menu is implemented as,-

Do

{

Menu 1: Purchase Tickets

Menu 2: View Ticket Sales

Menu 3: Exit System

Enter Menu selection, menusel

Switch (menusel)

{

Case 1: initialize adult_ticket and child_ticket as 0.

Call sub_menu (adult_ticket, child_ ticket);

 

Case 2: display, Total income from Ticket sales, Adult tickets sold and child tickets sold.

Case 3: Exits from the system.

Default:

}

} while (condition always true);

Step 4: Sub_menu( double adtc, double chtc)

{

Implement Ticket Purchasing Menu’

do

{

Menu 1: Adult Tickets

Menu 2: Child Tickets

Menu 3: Finalize Order

Menu 4: Cancel Order

User input for menu selection, menuSel1

Switch (menusel1)

{

Case 1:

User input for Number of Tickets as x.

If x is negative (<0.0) then re-enters the value of x.

Add x with the value of adtc.(Local variable of adult_ticket that stores added value of adult_ticket’s number in an order.)

Add x with the value of adult_ticket. (Global variable of adult_ticket that stores added value of adult_ticket’s number for all orders.)

 

Case 2:

User input for Number of Tickets as y.

If y is negative (<0.0) then re-enters the value of y.

Add y with the value of chtc.(Local variable of child_ticket that stores added value of child_ticket’s number in an order.)

Add y with the value of child_ticket. (Global variable of child_ticket that stores added value of child_ticket’s number for all orders.)

 

Case 3: calculate cost for adult ticket (number*$15.50) and add the cost with global variable, ad_cost. Again, calculate cost for child ticket (number*$5.75) and add the cost with global variable, ch_cost. The total cost is determined locally and updated with global variable, cost.

Display, Adult ticket number and child ticket number with total cost locally.

Return to the Main menu.

Case 4:

As, after choosing option 1 and 2 in the sub-menu the case 4 is executed so, the global variables for adult_ticket and child_ticket is subtracted from local variable, adtc and chtc respectively. If these global variables are negative after subtracting then these should be initialized by 0. Then, return to the main menu.

Default:

}

} while (condition always true);

3.Test Cases

 

S.No Test Case Expected Result Actual Result Pass/Fail
1. Application displays heading with Advanced functionality. Application should display headings and show the countdown for days. Application displays and shows the heading as well as actual countdown for days. pass
2. Applications display a menu Application should display a menu with options Purchase Tickets, View Ticket Sales and exit from system. Application displays a menu with options Purchase Tickets, View Ticket Sales and exit from system. Pass
3. If user enters 1, the system should be able to display another menu. After entering 1, another sub menu with Adult Tickets, Child Tickets, Finalize order and Cancel Order should be displayed. After entering 1, another sub menu with Adult Tickets, Child Tickets, Finalize order and Cancel Order displays. Pass
4. If user enters 1 and 2 in the sub-menu, the system should accept, Number of Tickets. If user enters 1 and 2 in the sub-menu, the system should accept, Number of Tickets for Adult and Child respectively. If user enters 1 and 2 in the sub-menu, the system accepts Number of Tickets for Adult and Child respectively. Pass
5. If user gives the Number of Tickets as negative, the system again accepts for Number of Tickets. If user gives the Number of Tickets as negative, the system should again accept for Number of Tickets. If user gives the Number of Tickets as negative, the system again accepts for Number of Tickets by ignoring the negative value. Pass
6. If user enters 3 in the sub-menu, the system calculates cost for adults and child tickets individually as well as total cost. Display appropriate message and returns to the main menu. If user enters 3 in the sub-menu, the system should calculate cost for adults and child tickets individually as well as total cost and display Adult Ticket number, child ticket number and total cost. Return to the main menu. If user enters 3 in the sub-menu, the system calculates cost for adults and child tickets individually as well as total cost and display Adult Ticket number, child ticket number and total cost. Return to the main menu. Pass
7. If user enters 4 in the sub-menu, then by re-initializing the variables, appropriate message display and return to the main menu. If user enters 4 in the sub-menu, then by re-initializing the variables, the system should display, “Order Cancelled” and return to the main menu. If user enters 4 in the sub-menu, then by re-initializing the variables, the system displays, “Order Cancelled” and return to the main menu. Pass
8. If user enters any number other than 1-4 for choosing option, then the sub-menu re-appears. If user enters any number other than 1-4 for choosing option, then the sub-menu should re-appear. If user enters any number other than 1-4 for choosing option, then the sub-menu re-appears. Pass
9. If user enters option 2 in the main menu, then appropriate message displays with total income, Adult ticket numbers and child ticket numbers. If user enters option 2 in the main menu, then appropriate message should display with total income, Adult ticket numbers and child ticket numbers for all orders. If user enters option 2 in the main menu, then appropriate message displays with total income, Adult ticket numbers and child ticket numbers for all orders. Pass
10. If user enters option 3 in the main menu, then appropriate message displays and exit from application. If user enters option 3 in the main menu, then appropriate message should display and exit from application. If user enters option 3 in the main menu, then appropriate message displays and exit from application. Pass
11. If user enters any number other than 1-3 for choosing option, then the main-menu re-appears. If user enters any number in the main menu other than 1-3 for choosing option, then the main-menu should re-appears. If user enters any number in the main menu other than 1-3 for choosing option, then the main-menu re-appears. Pass

Section 2: Program Development

The source code for the Application is given below,-

 

//package include for java input

import java.io.*;

import java.util.Scanner;

//package include for date calculation

import java.util.Date;

import java.util.Calendar;

import java.util.GregorianCalendar;

public class OlympicGames{

//global variables

static double ad_tckt=0.0;

static double ch_tckt=0.0;

static double x;

static double y;

static double ad_cost=0.0;

static double ch_cost=0.0;

static double cost=0.0;

static boolean flag=false; static int menuSel,menuSel1; static boolean f=false;

static Scanner ip=new Scanner(System.in);

public static void main(String[] args)

{

disp_heading(); //modularized code

menu_disp();

}

public static void disp_heading() //Base Functionality

{

//displaying heading

for(int i=0;i<70;i++)

System.out.print("*");

for(int j=0;j<20;j++)

System.out.print(" ");

System.out.println("FEDERATION UNIVERSITY AUSTRALIA OLYMPICS");

System.out.println();

System.out.println("Developed by , student ID , for ITECH1000 Sem 2 2016");

System.out.println();

//Advanced Functionality

GregorianCalendar d = new GregorianCalendar();

d.set(2016, Calendar.OCTOBER,1);

Date p=d.getTime();

/** Today's date */

Date today = new Date();

long currentTime = today.getTime();

// Get msec from each, and subtract.

long diff = p.getTime()-currentTime;

long res=diff / (1000 * 60 * 60 * 24);

for(int j=0;j<15;j++)

System.out.print(" ");

System.out.println("Let the games begin ! "+ res +" days to go !");

System.out.println();

for(int i=0;i<70;i++)

System.out.print("*");

}

public static void menu_disp() //Base Functionality

{

do {

System.out.println("\n\nPlease select an option from the Menu:"); //Displays the menu

System.out.println("1. Purchase Tickets");

System.out.println("2. View Ticket Sales");

System.out.println("3. Exit System ");

System.out.println("Enter menu select:");

menuSel=ip.nextInt();

//Enters value for menu selection

switch(menuSel){

case 1:

double ad_tkt=0.0;

double ch_tkt=0.0;

sub_menu(ad_tkt,ch_tkt); // function call with parameters and modularization

break;

case 2: for(int i=0;i<50;i++)

System.out.print("*");

System.out.println();

System.out.println("Total Income from Ticket Sales: $" + cost);

System.out.println();

System.out.println("Adult tickets sold:" +ad_tckt);

System.out.println("Child tickets sold:" +ch_tckt);

for(int i=0;i<50;i++)

System.out.print("*");

break;

case 3: System.out.println("The Federation University Australia olympics Ticketing system is now exiting....");

//Base Functionality,if user choices 3, exits from system

System.exit(0);

default:

break; // If user choices any number other than 1 to 3

}

}while(!flag); //condition always true, as flag !=TRUE

}

public static void sub_menu(double adtc, double chtc) //Standard Functionality

{

System.out.println("TICKET PURCHASING MENU ");

do

{

System.out.println("Your order currently contains"+adtc +" Adult ticket(s) and "+ chtc +" Child ticket(s)"); //Standard Functionality

f=false;

System.out.println("Please select an option from the list:");

//Displays the sub-menu

System.out.println("1. Adult Tickets");

System.out.println("2. Child Tickets");

System.out.println("3. Finalize Order ");

System.out.println("4. Cancel Order ");

System.out.println("Enter menu select:");

menuSel1=ip.nextInt();

//Enters value for menu selection

switch(menuSel1){

case 1:

do

{

System.out.println("Number of Tickets:");

x=ip.nextDouble();

}while(x<0.0);

adtc+=x;

ad_tckt+=x;

break;

case 2:

do

{

System.out.println("Number of Tickets:");

y=ip.nextDouble();

}while(y<0.0);

chtc+=y;

ch_tckt+=y;

break;

case 3:

double adcst=adtc*15.50;

ad_cost+=adcst;

double chcst=chtc*5.75;

ch_cost+=chcst;

double total=adcst+chcst;

cost+=total;

System.out.println("Your Order of "+ adtc +" adult ticket(s) and " + chtc +" child ticket(s) amounts to $"+ total); //Base Functionality

f=true;

break;

case 4:

ad_tckt-=adtc; ch_tckt-=chtc;

if (ad_tckt<0.0 || ch_tckt<0.0)

ad_tckt=ch_tckt=0.0;

System.out.println("Order Cancelled.");

adtc=0.0; chtc=0.0;

f=true;

break;

default:

break;

}

}while(!f);

} // end of function

}// end of class

Section 3: Testing

The Test Cases are:

S.No Test Case Expected Result Actual Result Pass/Fail
1. Application displays heading with Advanced functionality. Application should display headings and show the countdown for days. Application displays and shows the heading as well as actual countdown for days. pass
2. Applications display a menu Application should display a menu with options Purchase Tickets, View Ticket Sales and exit from system. Application displays a menu with options Purchase Tickets, View Ticket Sales and exit from system. Pass
3. If user enters 1, the system should be able to display another menu. After entering 1, another sub menu with Adult Tickets, Child Tickets, Finalize order and Cancel Order should be displayed. After entering 1, another sub menu with Adult Tickets, Child Tickets, Finalize order and Cancel Order displays. Pass
4. If user enters 1 and 2 in the sub-menu, the system should accept, Number of Tickets. If user enters 1 and 2 in the sub-menu, the system should accept, Number of Tickets for Adult and Child respectively. If user enters 1 and 2 in the sub-menu, the system accepts Number of Tickets for Adult and Child respectively. Pass
5. If user gives the Number of Tickets as negative, the system again accepts for Number of Tickets. If user gives the Number of Tickets as negative, the system should again accept for Number of Tickets. If user gives the Number of Tickets as negative, the system takes the negative value and calculates on it. Fail
6. If user enters 3 in the sub-menu, the system calculates cost for adults and child tickets individually as well as total cost. Display appropriate message and returns to the main menu. If user enters 3 in the sub-menu, the system should calculate cost for adults and child tickets individually as well as total cost and display Adult Ticket number, child ticket number and total cost. Return to the main menu. If user enters 3 in the sub-menu, the system calculates cost for adults and child tickets individually as well as total cost and display Adult Ticket number, child ticket number and total cost. Return to the main menu. Pass
7. If user enters 4 in the sub-menu, then by re-initializing the variables, appropriate message display and return to the main menu. If user enters 4 in the sub-menu, then by re-initializing the variables, the system should display, “Order Cancelled” and return to the main menu. If user enters 4 in the sub-menu, then by re-initializing the variables, the system displays, “Order Cancelled” and return to the main menu. Pass
8. If user enters any number other than 1-4 for choosing option, then the sub-menu re-appears. If user enters any number other than 1-4 for choosing option, then the sub-menu should re-appear. If user enters any number other than 1-4 for choosing option, then the sub-menu re-appears. Pass
9. If user enters option 2 in the main menu, then appropriate message displays with total income, Adult ticket numbers and child ticket numbers. If user enters option 2 in the main menu, then appropriate message should display with total income, Adult ticket numbers and child ticket numbers for all orders. If user enters option 2 in the main menu, then appropriate message displays with total income, but Adult ticket numbers and child ticket numbers for all orders are not displayed properly. Fail
10. If user enters option 3 in the main menu, then appropriate message displays and exit from application. If user enters option 3 in the main menu, then appropriate message should display and exit from application. If user enters option 3 in the main menu, then appropriate message displays and exit from application. Pass
11. If user enters any number other than 1-3 for choosing option, then the main-menu re-appears. If user enters any number in the main menu other than 1-3 for choosing option, then the main-menu should re-appears. If user enters any number in the main menu other than 1-3 for choosing option, then the main-menu re-appears. Pass

 

These assignments are solved by our professional Programming Assignment help expertsat My Assignment Services AU and the solution are high quality of work as well as 100% plagiarism free. The assignment solution was delivered within 2-3 Days.

Our Assignment Writing Experts are efficient to provide a fresh solution to this question. We are serving more than 10000+ Students in Australia, UK & US by helping them to score HD in their academics. Our Experts are well trained to follow all marking rubrics & referencing style.

Solution:Programming Assignment

Overview

This is an individual assignment that requires you to design, develop and test a small procedural Java program.

Timelines and Expectations

Percentage Value of Task: 20%

Due: 16:00 Friday the 2nd of September (week 7)

Minimum time expectation: 10 hours

Learning Outcomes Assessed

The following course learning outcomes are assessed by completing this assessment:

  • Identify and use the correct syntax of a common programming language
  • Recall and use typical programming constructs to design and implement simple software solutions
  • Reproduce and adapt commonly used basic algorithms
  • Utilise pseudocode and/or algorithms as a major program design technique
  • Write and implement a solution algorithm using basic programming constructs
  • Demonstrate debugging and testing skills whilst writing code
  • Develop self-reliance and judgement in adapting algorithms to diverse contexts
  • Design and write program solutions to identified problems using accepted design constructs

CRICOS Provider No. 00103D 1617 Assignment 1 specification.docx Page 1 of 9

ITECH1000 / ITECH5000 Programming 1 1617

Assessment Details

The Federation University Australia Olympic Games are about to commence! The games have been scheduled to begin on Saturday 1st October 2016, competitors are busy training and now it’s time to prepare to sell spectator tickets.

Your task is to design, develop and test a small application for recording ticket sales to this event.

Stage 1: Design

This stage requires you to prepare documentation that describes the function of the program and how it is to be tested. There is no coding or code testing involved in this stage. A document template has been provided for your use.

Requirements:

1) Read through Stage 2: Program Development to obtain details of the requirements of this

program.

2) Write an algorithm that describes how the program will operate.

  1. All program requirements – base, standard and advanced – must be included, even if you

do not end up including all these requirements in your program code.

  1. The algorithm must be structured logically so that the program would function correctly.

3) Prepare and document test cases that can be used to check that the program works correctly, once it has been coded. You do NOT need to actually run the test cases in this stage; this will occur in Stage 3: Testing.

  1. All program requirements – base, standard and advanced, must be included, even if you

do not end up including all these requirements in your program code.

  1. Make sure the test cases include checking of data entered by the user to make sure that

only valid data is accepted. If the user enters invalid data, the user should be informed of this and given another chance to enter the data. NB: As we have not covered exception handling, you may assume that the user will always enter an integer.

  1. Test cases should be documented using a template like the one below. You may include

extra information if you wish. At this stage, the Actual Result column will be left blank.

Test Case Expected Result Actual Result

The user selects to purchase adult tickets.

The user is prompted to enter the number of tickets to purchase.

CRICOS Provider No. 00103D 1617 Assignment 1 specification.docx Page 2 of 9

Stage 2: Program Development

Using the Design Documentation to assist you, develop a Java program that records spectator ticket sales at the gate for the Federation University Australia Olympic Games, implementing the requirements outlined in this section. These requirements have been broken into three groups:

  • Base Functionality includes the minimal level of requirements to achieve the essential components of this assignment. This group of requirements focuses on getting the code to work and on using the programming constructs we cover in class. You can expect to use constants, variables, loops, conditional statements and arithmetic operators for these requirements and you should look for opportunities to use these wherever you can. You will not receive full marks for implementing a requirement, even if it works, if you have not used the appropriate programming construct to do so.

At this level, you can decide if it is easier for you to code everything within a single method, or to modularize it straight away.

  • Standard Functionality ensures the code is modularized, and that method calls are used to ensure the program flows correctly. It allows data to pass from one method to another as parameters. It also includes providing a running total of tickets within an order, which is not essential for getting the program to work, but is useful information for the user to see.
  • Advanced Functionality provides a challenge task, and is best left until all the other requirements have been addressed. It requires looking at a Java API to find out how to use a class we have not covered in the course, and using this to provide a countdown of days remaining until the games commence.

All three groups require that you follow coding conventions, such as proper layout of code, using naming conventions and writing meaningful comments throughout your program.

Base Functionality:

  1. Display a welcome message when the program starts

  • The welcome message should have a row of asterisks at the top and the bottom, just long enough to extend over the text. Hint: Use a For loop for this.
  • The first line of the message should read “FEDERATION UNIVERSITY AUSTRALIA OLYMPICS” and be approximately centred in the row of asterisks by printing white space first. Hint: Can you modify the For loop from the previous step to print the white spaces?
  • A second line of the message should be blank.
  • The third line should read “Developed by” followed by your name and a comma, then “ student ID ”, then your student id, then finally “ for ITECH1000 Sem 2 2016”.
  • The fourth line should be blank.

CRICOS Provider No. 00103D 1617 Assignment 1 specification.docx Page 3 of 9

  1. Provide a menu from which the user can select to Purchase Tickets, View Ticket Sales or Exit.

This menu should be repeated each time after the user has chosen and completed an option until the user chooses to Exit. The user selects an option by entering the number next to it. If an invalid number is selected, the user is advised and shown the menu again to make another selection.

  1. When the user selects the Purchase Tickets option, provide another menu from which the user

can select Adult Tickets, Child Tickets, Finalise Order or Cancel Order. The user selects an option by entering the number next to it. If an invalid number is selected, the user is advised and shown the menu again to make another selection.

  1. Should the user select Adult Tickets or Child Tickets, they are prompted to enter the

Number of Tickets required. After entering the number of tickets required, they are returned to the Ticket Purchasing Menu so that they may choose to purchase additional tickets. The user may not choose to purchase a negative number of tickets, but a purchase of 0 tickets is permitted.

  1. Should the user select Finalise Order:
  2. The sale is processed by displaying the number of each type of ticket purchased and the total cost of the tickets in this order. An adult ticket costs $15.50; a child ticket costs $5.75.
  3. A record is kept of the total cost of tickets sold, the total number of adult tickets sold and the total number of child tickets sold. This is a combined total from all orders; there is no need to keep a record of the number of tickets in each individual order.

CRICOS Provider No. 00103D 1617 Assignment 1 specification.docx Page 4 of 9

iii. The user is returned to the menu from Step 2.

  1. Should the user select Cancel Order:
  2. The order is cancelled and a message displayed to confirm this to the user.
  3. The user is returned to the menu from Step 2.
  4. When the user selects the View Ticket Sales option, display the total value of ticket sales and both

the total number of adult tickets and the total number of child tickets sold across ALL orders. Highlight this message display with a row of 50 asterisks before and after the message. After the final row of asterisks, redisplay the menu from Step 2.

  1. When the user selects Exit System, quit the program with a message to the user.

CRICOS Provider No. 00103D 1617 Assignment 1 specification.docx Page 5 of 9

Standard Functionality:

  1. Update the Ticket Purchasing Menu so that a running total of tickets included in an order is

displayed until the order is finalized

  1. Modularize the code, correctly using method calls and passing data between methods as

parameters.

Advanced Functionality:

  1. Update the Welcome Message to include a countdown of the number of days to go until the

games begin.

  1. Use the GregorianCalendar class to manage your dates. You will need to import

java.util.GregorianCalendar to use this library.

  1. The countdown must be calculated based on the number of days between the time the

program runs, and Saturday 1st October 2016.

  1. There is no pre-defined method for finding the difference between two dates in this library. You will need to develop your own, using the features of the GregorianCalendar class.

CRICOS Provider No. 00103D 1617 Assignment 1 specification.docx Page 6 of 9

Stage 3: Testing

Using a copy of the test cases developed in Stage 1: Design, test the program you have developed in Stage 2: Program Development. Document your results, including both failed and successful tests.

Note: Please do not leave out any failed tests. If your testing highlights that your program has not worked correctly, then the failed tests help to demonstrate that you have been testing your program properly.

To show that you have tested your program, include small (but readable) screen captures in your Actual Results as well as any explanatory comments. Microsoft Windows includes a Snipping Tool that is useful for taking captures of the relevant parts of the screen.

You may test your program in phases if you wish. Stage 2: Program Development provides three separate groups of functionality in the requirements, working from the minimal level of requirements through to more advanced concepts. Each of these groups can be tested individually.

Base Functionality:

This phase requires you to check that the base functions (displaying welcome message when the program starts, showing a menu of options until the user chooses to exit, purchasing tickets, viewing ticket sales and exiting the system) have been implemented.

Standard Functionality:

In addition to the Base Functionality, this section includes displaying a running total of tickets that have been added to an order until such time as the order has been finalized. This new functionality must also be tested.

If you originally wrote and tested the Base Functionality by including all the code in a single method, this phase also requires that you modularize your code, and use method calls and pass data between methods to ensure your program still runs correctly. This means all your code will need to be re- tested to ensure that all the previous functionality still works.

Advanced Functionality:

This phase requires testing the code that calculates and displays the number of days until the games comments in the welcoming message shown when the program starts.

Find Solution forProgramming Assignmentby dropping us a mail at help@myassignmentservices.com.au along with the question’s URL. Get in Contact with our experts at My Assignment Services AU and get the solution as per your specification & University requirement.

RELATED SOLUTIONS

Order Now

Request Callback

Tap to ChatGet instant assignment help

Get 500 Words FREE