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

  Possible effect that multithreading could have

Imagine you are a graphic artist working on an animation for a movie. Describe at least one (1) possible effect that multithreading could have on your work process. Support your response with at least (1) example of the effect of multithreading

  Program to read the names of users

Write a program to read the names of users and number of units consumed and print out the charges with names. Use the concepts of classes.

  Create the java source code files for the classes listed in

Create an abstract base class, Animal. The single constructor requires a String to indicate the type of animal, which then is stored in an instance variable.

  How are servlets and jsps deployed inside weblogic

How are Servlets and JSP's deployed inside WebLogic? In a Weblogic CMP EJB, how to obtain the maximum value in the specified database column? In WLQL is there something similar to MAX() function in SQL?

  Create class called hospital and add all relevant attributes

Create a class called Hospital and add all the relevant attributes for the created class - Create a User's super class that contains all the properties common to the all the users that will be using the Hospital patient billing system.

  What are the merits and demerits of the use of mainframes

write a 200- to 300-word short-answer response to the followingwhat are the advantages and disadvantages of the use of

  Complete the code to counts the number of lines input

Complete the code to counts the number of lines input by a user until the user enters the string ENDOFDATA (must be uppercase letters, no spaces) on a line by itself.

  Write a custom java exception class named badarrayexception

A constructor taking a String parameter (the exception message) that must be passed to the parent Exception(String) constructor.

  Create a class named movie that can be used with a video

extend above with a Rental class. This class should store a Movie that is rented, an integer representing the ID of the customer who rented the movie, and an integer indicating how many days late the movie is.

  Develop and test stand alone java applications

Demonstrate an understanding of Object-Oriented Programming concepts in Java.

  Write a computer program that prompts the user for a number

Write a computer program that prompts the user for a number, creates an array for that number of random integers, and then uses the sophisticated form of bubble sort to order the array

  Write a program to display the customer''s name

Write a program that prompts the salesperson for the name of the customer and the price of the textbooks sold to that customer.• The program should display the customer's name and the total compensation

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