Develop a menu driven console java program

Assignment Help JAVA Programming
Reference no: EM131114349

JAVA Program using array of objects

You are required to develop a Menu Driven Console Java Program to demonstrate you can use Java constructs including input/output via GUI dialogs, 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 and is available on the course 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 have to complete the code. You will need to write comments in the supplied code as well as your own additions.

What to submit for this assignment

The Java source code:
o Car.java
o CarPark.java

Assignment Specification
You have completed the console program for processing cars parked at the Rocky car park. We are going to extend this application so the car's licence plates and hours spent parked can be stored in an array of objects.

The program will run via a menu of options, the file CarPark.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.

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

The Car class will be very simple it will contain two private instance variables:
o licencePlate as a String
o hours as an integer
You can also have constants for the fee values i.e $7.50 and $4.50. The following public methods will have to be implemented:
o A default constructor
o A parameterised constructor
o Two set methods (mutators)
o Two get methods (accessors)
o A method to calculate and return the fee. This calculation will be the same as in assignment one i.e. First hour is $7.50 and the remaining hours will be $4.50 per hour.

Note: following basic database principles calculated values are not usually stored so in this case we will not store the fee as a instance variable, but use the calculateFee() method when we want to access the fee.

CarPark class
Once the Car 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 licence plates and hours in an array of Car objects. Declare an array of Car objects as an instance variable of CarPark class the array should hold twenty cars.
You will need another instance variable (integer) to keep track of the number of the cars being entered and use this for the index into the array of Car objects.

Menu options
1. Enter licence plate and hours parked: enterCar()
For assignment two we are going to use the GUI dialog showInputDialog() for our input. You will need to create the following two dialogs to receive the input from the user. You will not implement the functionality of the cancel key (need to use exceptions for this).

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 licence plate cannot be blank i.e. not null and the hours parked needs to be between one and twelve (1-12) inclusive.
Use the following pseudocode as a guide how to do this.

READ value
WHILE value is incorrect OUTPUT Error message READ value
END WHILE

Output the following error dialogs:

When the licence plate and hours parked has been entered successfully into two local variables you will need to add these values into the Car object array, you will also need to increment a counter to keep track of the number of cars you have entered and the position in the array of the next car to be entered.

When the maximum number of cars is reached do not attempt to add any more cars and give the following error message:

When the car details have been successfully entered display the details of the car and the fee to be charged on the console screen.

Note: For the next three options you should ensure at least one car has been entered and give an appropriate error message if it there are no cars entered, for example:

2. Display all licence plates, hours and fees: displayAllCars()
When this option is selected display all of the cars which have been entered so far.

Review the text p.933for the use of the printf method and using a format string. You could also use String.format() to format your output.

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 car: searchCar()
You can just use a simple linear search which will be case insensitive. Use the showInputDialog() method to input the name (you can share this functionality from enter car).

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

If the search is unsuccessful display an appropriate message.

Remember the welcome and exit messages as per assignment one.

Extra Hints

Your program should be well laid out, commented and uses appropriate and consistent names (camel notation) for all variables, methods and objects.

Make sure you have no repeated code (even writing headings in the output) Constants must be used for all numbers in your code.

Look at the marking criteria to ensure you have completed all of the necessary items

Refer to a Java reference textbook and the course and lecture material (available on the course web site) for further information about the Java programming topics required to complete this assignment. Check output, check code and add all of your comments, complete report and the UML class diagram.
Supplied Code

Download, compile and run the supplied code available from the course web site.

You will see the menu interface has been implemented and you have to implement the underlying code, use the supplied method stubs and add you own methods.

Again no code should be repeated in your program.

Attachment:- java assignment.pdf

Reference no: EM131114349

Questions Cloud

Determine the voltage across the 1-a current : By using the mesh-current method, determine the voltage across the 1-A current source of the circuit of Figure P2.2.7, and verify by nodal analysis.
Compute the amount of the inventory at december 31 : On December 31, 2011, the inventory at prices existing on that date was $195,500, and the price level was 115. Compute the inventory on that date under the dollar-value LIFO method.
How many square kilometers of land did she purchase : Buying a House. Sadaf Din is purchasing a house selling for $215,000. To obtain her mortgage, Sadaf must make a 20% down payment. The current mortgage rate is 4.5%. Determine the amount of the required down payment.
Determine the current i through the 10-? resistor : Determine the current I through the 10-Ω resistor of the circuit of Figure P2.2.5 by employing the node-voltage method. Check by mesh analysis.
Develop a menu driven console java program : Develop a Menu Driven Console Java Program to demonstrate you can use Java constructs including input/output via GUI dialogs, Java primitive and built-in types, Java defined objects, arrays, selection and looping statements and various other Java ..
Was the new mba a good hire : which is presented below, to determine the amount of cash Eastern Trading needs to hold in precautionary balances under its current decentralized system and the level of precautionary cash it would need to hold under a centralized system. Was the new..
Have you been a mentor or have been mentored in workplace : Have you been a mentor or have been mentored in your workplace? What are the benefits of both (mentoring a new employee or being mentored)?
Sisko company has used the dollar value lifo method : (Dollar-Value LIFO) Sisko Company has used the dollar-value LIFO method for inventory cost determination for many years.
Determine the current in the 0.5-? resistor of the circuit : find the voltage across the 8-A current source in the circuit of Figure P2.2.6 with the use of nodal analysis.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Explain why the teller application can call the withdraw

Explain why the Teller application can call the withdraw and deposit methods using a SavingsAccount object reference, even though we did not define these methods

  Constructor that initializes the three automatic properties

Create a class called Date that adds three pieces of information as automatic properties-a   month (type int), a day (type int) and a year (type int).

  Identify all of the lines of code within the program

Identify all of the lines of code within the program that are associated with obtaining user input. This can be done by either copying the lines into your answers or highlighting the lines within the code.

  Which is the best character high value

When updating a master file with data from a transaction file, what should happen for an addition record when a match is found in the master file?

  Tasks for an array of integers

Write array methods that carry out the subsequent tasks for an array of integers by completing the ArrayMethods class below. Test each method.

  Design and implement a sorting algorithm

Your task is to design and implement a sorting algorithm and running time grows as a linear function of the array

  What are the steps necessary to create a jar file

What are the steps necessary to create a JAR file where the main entry point is identified?

  Allows the user to enter students names followed

Write a program that allows the user to enter students names followed by their test scores and outputs the following information(assume that the maximum nmber of students in the class is 50

  Difference for class linked bag and test into main program

write a method difference for the class linked bag and test into main program.

  Construct a fileinputstream with the file name

Write a program that will search a text file of strings representing numbers of type int and will write the largest and the smallest numbers to the screen. The file contains nothing but strings representing numbers of type int one per line. Your s..

  An n n matrix is called a positive markov matrix

An n n matrix is called a positive Markov matrix if each element is positive and the sum of the elements in each column is 1. Write a program MarkovMatrix.java that prompts the user to enter a 33 matrix of double values. Use a method with the followi..

  Write the code with comment and output resultinterface and

write the code with comment and output resultinterface and polymorphismimplement a class quiz that implements the

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