INTRODUCTION TO PROGRAMMING ASSIGNMENT

146 views 7:53 am 0 Comments March 1, 2023

Rocky Blues program.

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 per cent discount for a booking with more than five lessons and a twenty per cent 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.

You are to write a Java Console Application (RockyBlues.java) which will allow staff to enter the details of N booking names and the number of lessons and whether the student wants to purchase a guitar 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 lessons and clients for the booking, it will also prompt the student to ask if they want to purchase a guitar, it will then display the charge (see sample output below for formatting details).

When all the bookings have been entered you need to report the maximum and a minimum number of lessons per booking and the relevant booking name, the average number of lessons 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 lessonsThe program will also prompt the user if the student wants to purchase a guitar (if “Y” or ”y” is entered then mark the student as wanting to purchase a guitar, any other response will assume no guitar is required). 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 to ensure that a booking name is entered. For this assignment, there is no need to ensure the name is a valid name (e.g. entering 1 for the name would be allowed). The number of lessons must be greater than or equal to one and you will also need to implement a validation loop to ensure that a valid number of lessons is entered.

The program will number each booking in the input prompt.

  • When N bookings have been entered, you will output a heading for the statistics “Statistical information for Rocky Blues”, the minimum and a maximum number of lessons booked and the booking names with these minimums and maximums, and then the average number of lessons per booking is (formatted to two decimal places) (see sample output below). Note: If more than one booking has an equal maximum or minimum lessons you just need to only output one of these cases.
  • Display a welcome message at the beginning “Welcome to the Rocky Blues Management System” and an end message e.g. “Thank you for using the Rocky Blues Management System” and the final line “Program written by <your student ID>” (see sample output below).

The numeric literal values N, number of lessons for the different discount levels, discounts and lesson cost must be represented as constants.

Implementation

Many students have never written a program before so this is a fairly simple assignment that 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 RockyBlues class which will contain just the main method, COMPILE! (Fix any errors and repeat).

Please include a header comment which includes your name, student ID, date, filename and a brief description of the program.

Implement the welcome message, COMPILE, RUN and TEST! 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 iterate N Times, COMPILE, RUN and TEST! (use N = 3 for development)

Declare variables to hold the booking name and the number of lessons (String and int), COMPILE, RUN and TEST!

Within the loop: prompt and read the booking name, COMPILE, RUN and TEST! Add the prompt and read for the number of lessons, COMPILE, RUN and TEST!

Declare a boolean variable to store true or false if the student wants to purchase a guitar, add the prompt to ask the student if they want to purchase a guitar and set the boolean variable accordingly, COMPILE, RUN and TEST!

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

Output the description of the booking (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 lessons 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 lessons 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 lessons and the corresponding booking names and the total amount of charges collected.

Calculate the average number of lessons per booking (ensure you are performing a floating-point calculation).

Output the statistics as indicated in the screen shot below. Finally, print the end message.

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