Background

Red Fan Advertising requires a simple newspaper advert price calculator prototype to demonstrate key features. The size, position and type (colour or black & white) of the advert are used to calculate the price.

Adverts position can be:

  • In the run of the paper (i.e. anywhere they can be fitted around content and other adverts). These adverts can be colour or black & white.
  • On the front Cover (can be colour or black & white)
  • On the Back Cover (can be colour or black & white)
  • On a special double-sided wrapper that covers the whole paper (always charged as colour).

The height of the advert is measured in centimetres (must be between 10 and 70 and a multiple of 5).

The width is measured in columns (maximum of 5).

The basic price is calculated using the following formula: Height x Width x Rate (see table below).

Advertising Rates (in pence) See image.

If artwork is required, a 15% charge is applied to the basic price (capped at $30).

Each advert is assigned a reference number (e.g. A123ED A letter followed by three digits and two letter. The first letter can only be A for Account Transaction or C for Cash Transaction).

Account transactions receive a 10% discount.

All calculations are performed on the pence values and decimal portion disregarded.

Advert details also include the client name (eg: S Jones) maximum of 30 characters

As well as processing orders at its main office, Red Fan also receive order data from an agent in the form of a text file (a single file containing multiple advert details).

When required, summary outputs should be displayed using the following format:

+---------------------------------------+
| |
| Client: S Jones |
| |
| Date: 15 Nov 2014 Ref: A123ED |
| Position: Run Type: Colour |
| Columns: Three Height: 15cm |
| |
| Artwork: No Charge: None |
| |
| Discounted Price: $57.28 |
| |
+---------------------------------------+

Notes:

  • Number of columns must be displayed as a word (One, Two, etc).
  • Price is centred and the word discount only appears if a discount has been applied.
  • If there is no artwork charge, the word none should be displayed for charge.
  • The border should be included with the summary.

Requirements

A prototype console application (no GUIs or GUI dialogs) is required. Your prototype should display a menu similar to the following:

  • Enter new Advert
  • Display Summary of Adverts
  • Display Summary of Adverts for Selected Month
  • Find and display Adverts
  • Exit

Once an option is selected and processed, the menu should be redisplayed until the exit option is selected. Each operation is described below:

Option 1: Enter new Advert

Ask the user for the inputs: client name, type, position, height, width, artwork required and reference. Note: All inputs should be validated.

Calculate the total and discounted prices for the advert.

Display the advert summary (it must use the format in the example).

Save (append) the data for the advert to the text-based summary file (adverts.txt). Each line in the file must hold the details for a single advert with the following information separated by spaces or tabs:

  • Advert Date (todays date - see technical details for format).
  • Advert Type (1=Black & White, 2=Colour and 3=Wrapper)
  • Advert Position (1=Run, 2=Front, 3=Back and 4=Wrapper)
  • Height (0 for Wrapper adverts)
  • Width (0 for Wrapper adverts)
  • Artwork required (Y or N)
  • Reference Number.
  • Price (in pence).
  • Client Name.

Option 2: Summary of Adverts

User is asked to select the main (main.txt) or agent (agent.txt) adverts and a summary of the following is displayed:

  • Total number of adverts.
  • Number of colour adverts (inc. Wrapper).
  • Average pre-discount price of adverts (excluding wrapper adverts).
  • Total number of adverts per month (assume the files only include data for the current year). Show an entry for all twelve months even those that have an entry of zero.

A sample agent file can be downloaded from Blackboard. For the supplied agent file, the output should look similar to the following:

Total Number of adverts: 1000
Number of colour adverts (inc. Wrappers): 597
Average pre-discounted price of adverts (exc. Wrappers): 210.40
Number of adverts per Month:
Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
88 62 101 73 90 92 86 108 61 77 75 87

Option 3: Summary of Adverts for a Selected Month

The user is asked to select the main or agent adverts and to enter a month. A summary of adverts (as specified in option 2) should then be displayed for the specified month.

Option 4: Find and Display Advert

The user is asked to select the main or agent adverts and enter the search text. The selected file should be searched for any matches (full or partial) against the reference or client name. For example entering DE would match against reference number A123DE and Client Name C Sanderson.

For each matching entry, the advert summary (see option 1) should be displayed.

Option 0: Exit

Display an appropriate message and exit the application.

Test Requirements

As well as developing the prototype, the client requires a test plan for the application that demonstrates how each feature will be tested to ensure that it performs as expected. The test plan should use the following format:

Description Values/Input Expected outcome Actual outcome

Once the test plan has been completed, use it to check your design and application. If any of the tests fail, update your application and re-test (keep the original entry that failed in the plan along with the new entry for the re-test).

Technical Information

Name your project AdvertManager.

Data files must be named main.txt and agent.txt. A sample of the agent file can be downloaded from the Assessment section of the blackboard module.

The implementation must include an Advert class that represents a single advert. This class should use appropriate encapsulation and not include any keyboard input or console output.

The following method will get todays date:

public static String getDate()
{
Calendar cal = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("dd-MMM-yyyy");
return sdf.format(cal.getTime());
}

You will need to import java.util.Calendar and java.text.SimpleDateFormat;

Internally use integers for monetary values (hold them as pence). Display as pounds and pence by dividing the value by 100 and using the printf method to display for example:

System.out.printf("$%.2f ", amount / 100.0);

The prototype must be developed in NetBeans.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.