Declare an array of booking objects

Assignment Help JAVA Programming
Reference no: EM133150257

Assessment item - JAVA Program using array of objects

Objectives
This assessment item relates to the unit learning outcomes as stated in the Unit Profile.

Details
For this assignment, you are required to develop a Menu Driven Console Java Program to demonstrate you can use Java constructs including input/output via the console, Java primitive and built-in types, Java defined objects, arrays, selection and looping statements and various other Java commands. Your program must produce the correct results.

The code for the menu and option selection is supplied: RockyBluesMenu.java and is available on the unit website, you must write the underlying code to implement the program. The menu selections are linked to appropriate methods in the given code. Please spend a bit of time looking at the given code to familiarise yourself with it and where you must complete the code. You will need to write comments in the supplied code as well as your own additions.

Assignment Specification
You have completed the assignment one console program for processing bookings for Rocky Blues School. We are going to extend this application so the booking names, number of lessons and guitar purchase can be stored in an array of objects, do not use ArrayList.

The program will run via a menu of options, the file RockyBluesMenu.java has been supplied (via the Moodle web site) which supplies the basic functionality of the menu system.
Look at the code supplied and trace the execution and you will see the menu is linked to blank methods (stubs) which you will implement the various choices in the menu.

Booking class
First step is to create a class called Booking (Booking.java).

The Booking class will be very simple it will contain three private instance variables:
o bookingName as a String
o lessons as an integer
o purchaseGuitar as boolean

The numeric literal values maximum booking, minimum lessons (i.e. one), the different discount levels and discount values, guitar cost and lesson charge must be represented as constants.

The following public methods will have to be implemented:
o A default constructor
o A parameterised constructor
o Three set methods (mutators)
o Three get methods (accessors)
o A method to calculate and return the charge for the booking - calculateCharge(). This calculation will be the same as in assignment one. Use constants for all numeric literals.

You should use the following method header:

public double calculateCharge()

Note: you do not need to pass lessons or purchaseGuitar as parameters as you can access the instance variables directly within the class.

The Rocky Blues School offers personal blues guitar lessons for people in the Rockhampton region. The lessons are in half hour blocks.
The cost of a lesson is $29.95.
To encourage students to book more lessons, the management has decided to give a ten percent discount for a booking with more than five lessons and a twenty percent discount with a booking of more than ten lessons on the total lesson charge (not for the purchase of a guitar see below).

Rocky Blues also offers the students a chance to purchase a guitar for $199.00. This is the same as assignment one.
Note: Following basic database principles, calculated values are not usually stored, so in this case we will not store the charge as a instance variable, but use the calculateCharge() method when we want to determine the charge.

RockyBluesMenu class
Once the Booking class is implemented and fully tested, we can now start to implement the functionality of the menu system.

Data structures
For this assignment we are going to store the booking names and number of lessons and the purchaseGuitar boolean value in an array of Booking objects.
Declare an array of Booking objects as an instance variable of RockyBluesMenu class the array should hold ten bookings.
You will need another instance variable (integer) to keep track of the number of the bookings being entered and use this for the index into the array of Booking objects.

Menu options
1. Enter booking name and number of lessons and guitar purchase: enterBooking() You will read in the booking name and number of lessons and guitar purchase as you did in assignment one.

Data validation (you can implement this after you have got the basic functionality implemented) You will need to validate the user input using a validation loop.
The booking name cannot be blank i.e. not null and the number of lessons needs to be greater than or equal to one, the same as assignment one.

When the booking name and number of lessons and guitar purchase have been entered successfully into three local variables you will need to add these values into the Booking object array using the new keyword and the parameterised constructor, you will also need to increment a counter to keep track of the number of bookings you have entered and the position in the array of the next booking to be entered.

When the booking details have been successfully entered, display the details of the booking and the charge as follows:

Hint: use the format string in printf of "%-30s%-11s%-18b$%5.2f\n", %-18b is the placeholder for the boolean (guitar purchase). This will line up the output correctly under the heading.

Note: For the next three options, display all, statistics and search you should ensure at least one booking has been entered and give an appropriate error message if it there are no bookings entered and for the sorting option you must ensure at least two bookings have been entered, for example:

2. Display all booking names, number of lessons, guitar purchase and charges:

displayAllBookings()

When this option is selected display all the bookings which have been entered so far.

3. Display statistics: displayStatistics()
When this option is selected you will display the statistics as per assignment one. You can loop through your array of objects to calculate this information.

4. Search for a booking: searchBookings()
You can just use a simple linear search which will be case insensitive.

If the search is successful display the details about the booking.

If the search is unsuccessful display an appropriate message.

5. Sort the bookings: sortBookings()

This option you will sort the bookings alphabetically (case insensitive) by the booking names, you can use any sorting algorithm which you like, do not use any in-built sort methods. Display the sorted list after the sort is complete.

Remember the welcome and exit messages as per assignment one.

Attachment:- JAVA Program using array of objects.rar

 

Reference no: EM133150257

Questions Cloud

Find an internet resource that provides information : Find an Internet (online) resource that provides additional information and/or a different perspective on the central theme of the resource
Determine the annual payment : Determine the annual payment on a $500,000, 12% business loan from a commercial bank that is to be amortized over a five-year period
What amount of net sales would nike report : Nike has a 60-day return policy for its wholesale customers. What amount of Net Sales would Nike report related to the Footlocker sale
What is the gain in the realization of the assets : Partners Carlo, Diego, and Edgar who share profits and losses in the ratio of 5:3:2, What is the gain/(loss) in the realization of the assets for Period 1
Declare an array of booking objects : Declare an array of Booking objects as an instance variable of RockyBluesMenu class the array should hold ten bookings
How much is debited to work in process inventory : Assuming that payroll withholdings are ignored and Jobs #60 and #61 are the only jobs being performed, how much is debited to Work in Process Inventory
Implement the functionality of the menu system : Implement the functionality of the menu system and When the booking name and number of lessons and guitar purchase have been entered
Record the service on account on march : Grace pays for those services on March 20. For Medical Waste Services, record the service on account on March 12 and the collection of cash on March 20
Calculate net revenue associated with these transactions : The customer makes full payment of the balance owed on April 30. Calculate net revenue associated with these transactions

Reviews

Write a Review

JAVA Programming Questions & Answers

  Create a structure named dog with a string field

Create a Structure named dog with a string field for the Dog's name. Create a Structure named Cat with a string field for the Cat's name.

  Implement a singly linear linked list

Prepare a C++ using visual studios program to implement a singly linear Linked List - You need to implement singly link list in C++.

  Objects-type case

With object-oriented programming, classes and objects can be used to avoid "type- case" statements. Here is a program in which a form of case statement is used that inspects a user-de?ned type tag to distinguish between different classes of shape ..

  What is the difference between arrays and arraylist

What is the difference between arrays and ArrayList? What are the advantages and disadvantages of an ArrayList

  Develope a gui interface

During an earlier in-lecture exercise, you developed a GUI interface like the one - You may choose how and where the price will be displayed

  Create an array to hold four movie objects

Create an array to hold four movie objects and fill the array with objects: two movies and two documentaries.

  Create a default and parameterized constructor

Create a default and parameterized constructor. Create sets/gets for all instance variables. Create a get method to calculate and return the profit or loss.

  Implement bounded partial queue using signaling mechanism

Can you explain the reason? You can run the experiments on ecen5033.colorado.edu. Submit the code as well as experimental results - Implement both these schemes in Java. Each of the methods foo() and bar() just sleeps for 20 milliseconds.

  1 write an application class that contains several

1 write an application class that contains several methods.nbspthe first method should be named greeting and should

  Create an array to store letter frequency counts

implements the Comparable interface, thus there must be a compareTo() method which should compare two LetterCount objects by their count values

  Write java program to utilizes gui with five text fields

Write down the program called MaxMinAvgGUI.java which utilizes GUI with five(5)text fields which asks user to enter 5(five) decimal numbers. 1(one)number in each text field.

  Create a program that will ask for gallon used

Create a program that will ask for both gallon used and mileage travelled; calculate the MPG. Create a program that ask for a radius of a circle and has the ability to return both the Area and Circumference.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd