Java Program




Introduction to Programming


  Assignment Details

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

You are only allowed to use techniques which have been covered in the first six weeks of the course, you must use the Scanner object for input and no advanced data structures like arrays will be used. Instructions for this appear in the implementation section of this specification.


What to submit for this assignment

The Java source code:

o       NemoReefTours.java

A report including a flow chart (UML activity diagram) to depict your validation loop for reading the number of passengers, how long it took to create, any problems encountered and screen shots of the output produced. (Use Alt-PrtScrn to capture just the console window and you can paste it into your Word document). You should test every possibility in the program.

 o       ReportAss1.docx

You will submit your files by the due date using the “Assignment 1” link on the Moodle unit website in the Assessment Block or in the relevant week.


Assignment specification

Nemo Reef Tours program

Nemo Reef Tours is company which takes passengers on a tour of the Great Barrier Reef, the tours depart at 8:00 am and returns around 5:00 pm. A smorgasbord lunch is also provided along with the opportunity to snorkel among the exotic fish and coral.

This program will allow staff at Nemo Reef Tours to compute the cost of a group of passengers to take the tour. There is a flat fee of eighty five dollars and fifty cents ($85.50) per person.

The management of Nemo Reef tours would like to encourage more passengers to take the tour, so it was decided there would be discounts for a larger number of passengers in the booking group. The discounts are as follows:

Charge per person $85.50 (as above).

One to two passengers: no discount.

From three to five passengers: 10% discount.

From six to ten passengers: 15% discount.

More than ten passengers: 20% discount.

The Nemo Reef Tours management has asked you to write a program to help employees determine the charges for booking a tour and to also produce some statistics

You are to write a Java Console Application (NemoReefTours.java) which will allow employees to enter the details of N booking names and the number of passengers for each booking. N should be equal to the highest digit in your student ID, use N=3 if your highest digit is less than three. For each booking the program will prompt for and accept the booking name and the number of passengers for the booking, it will then display the charge (see sample output below for formatting details).

For simplicity the bookings will be for the following day.

When all the bookings have been entered you need to report the maximum and minimum number of passengers per booking and the relevant booking name, the average number of passengers per booking and the total charges which have been collected.

The required Java Console Application should allow the user to:


1.     For each of the N bookings: enter the Booking name, and then enter the Number of passengers. The program will output the charge for the booking. All dollar values will be formatted to two decimal places (see implementation below with help for doing this).


2. You must ensure the booking name is not blank so you must implement a validation loop so a booking name is entered. The number of passengers must be a positive number (non-zero) and you will also need to implement a validation loop so valid number of passengers are entered.

The program will number each booking in the input prompt.

3.   When N bookings have been entered, you will output a heading for the statistics “Statistical information for Nemo Reef Tours”, the minimum and maximum number of passengers in the booking groups and the booking name with these minimums and maximums, and then what the average number of passengers per booking is (formatted to two decimal places) (see sample output below). Note: if more than one booking has an equal maximum or minimum passengers you just need to only output one booking name.


4.   Display a welcome message at the beginning “Welcome to the Nemo Reef Tour Management System” and an end message e.g. “Thank you for using the Nemo Reef Tour Management System” and the final line “Program written by <your student ID>” (see sample output below).

The numeric literal values N, number of passengers for the different discounts and discounts must be represented as constants.

Implementation

A large number of students have never written a program before so this is a fairly simple assignment which can be written in the main method of your class. Follow the steps outlined here and build your program up in a step by step fashion and always compile your program at each stage so you are always working on error free code.

Start by creating your NemoReefTours class which will contain just the main method, COMPILE! (Fix any errors and repeat)

Implement the welcome message, COMPILE and RUN!

Declare your Scanner object(s), COMPILE!
Note: In order to combat the problem of the Scanner objects reading both textual and numeric data a good way to counter this is to declare two Scanner objects, one for reading text and

another for reading numbers, or you can clear the buffer after the int read using nextLine()

Create a loop to loop N Times, COMPILE! (use N = 3 for development)

Declare variables to hold the booking name and the number of passengers (String and int),

COMPILE!

Within the loop: prompt and read the booking name, COMPILE and RUN!

Add the prompt and read for the number of passengers, COMPILE and RUN!

Calculate the tour charges using the pricing structure above, COMPILE, RUN and TEST until this is correct.

Output the description of the transaction (see sample output below)

Output all dollar values and average to two decimal places:

USE: System.out.printf("%.2f", charge);

Add the validation loops for reading the data (you can do this last if you like)

Use if statements to determine if the number of passengers is maximum or minimum, (you will have to think about this). Output the minimum and maximums after the loop, COMPILE and RUN until you have this correct. You may want to set your original max and min variables to very small and

very large numbers using Integer.MIN_VALUE and Integer.MAX_VALUE.

You will need to add up the number of passengers as you go so you can calculate the average.

After the loop you will output the statistics which you have gathered in the loop. You should have the maximum and minimum number of passengers and the corresponding booking names and the total amount of charges collected.

Calculate the average number of passengers per booking.


Output the statistics as indicated in the screen shot below.

Finally print the end message.

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

For this assignment you will not worry about checking data types.

Refer to a Java reference textbook and the unit and lecture material (available on the course WEB site) for further information about the Java programming topics required to complete this assignment.

Check the marking guide (last page) to ensure you have completed every task. You need to match the output as shown below.


Typical screen shot of the program executing is as follows:



 To get solution visit our website www.sourceessay.com

Comments

  1. Thanks for sharing this fantastic post that I came upon. It is exactly what I was hoping to see, and I hope you will continue to share such a wonderful piece in the future. This article scroll speed test may be of interest to you because you have excellent insights on this. Examine your scrolling speed. For further details, see this article.

    ReplyDelete

Post a Comment

Popular posts from this blog

Assignment Help: Add Valuable Factors In Your Learning Skills

Language Techniques Every Student Must Know

The Helpful Essay Writing Guide: Structure, Outline, Tips And Format