Created by K. Vander Meer to accompany Final Project for CO116
CO116 Final Project Holiday Donation Drive Program
Worth: 200 points
Due: Wednesday, December 10, 2014 at NOON – NO extensions will be granted. I know…it’s not in the giving spirit, but I have to get grades in by December 12.
Help: You are to work alone on this project. Tutors will not assist on Final Programs or Exams. I have provided you with this Design Document which is full of helpful information on solving this program, and a Final Project Setup Video that will show you how to set up your project.
Table of Contents
CO116 Final Project Holiday Donation Drive Program
Software Design for Final Project Holiday Giving Drive
Stage 1: Requirements Specification
Stage 2: System Analysis
Stage 3: System Design
Stage 4: Implementation
Stage 5: Test Plan
Software Design for Final ProjectHoliday Giving Drive
Holiday Donation Drive ~ Write a program that will allow an administrator of the annual Holiday Giving Drive to enter site names, cash donations, and food pound donations for the 6 sites around the city. The program will calculate total cash, total pounds of food, determine the best site with the highest cash and food donations. The program will display each site donations, the totals for all sites, and the sites with the best results.
The program should include the following techniques from various chapters:
- Must use arrays
- Must include methods (I will show you how to set up the methods in the video)
- Must include range checking error code for any input of a number
- Must include a loop to run the program multiple times
- Must include loops and decision statements throughout the program
For a complete program description, read the Software Design document provided below. My design is just one way you can code this problem. Your code, variable names, methods used may be different, as long as you meet the requirements.
Stage 1: Requirements Specification
The program must satisfy the following requirements:
- The program should ask the user the following information:
- The site names for 6 locations (into an array)
- The cash donation for 6 locations (into an array)
- The food donations in pounds for 6 locations (into an array)
- Is there another test they want to process, meaning do they want to run the program again?
- Based on the input, the program will calculate the total cash donated for all 6 sites and the total pounds of food collected for all 6 sites. It will determine the highest cash donation, the highest pounds of food donated, and the name of each corresponding site location.
- The program should then display a report of each individual site name with cash and food donations, the total cash and total food donated, the highest cash donation with the corresponding site location name, and the highest food donation with the corresponding site location name.
Stage 2: System Analysis
Calculations: The following calculations must happen in order to meet the system requirements:
- In order to calculate the total cash donation and total food donation, use accumulation.
- In order to determine the max cash donation and max food donation, use an if statement within a for loop (see 3.e below under System Design and watch video)
Variables: Most variables should be defined in a global location using the static keyword. If a variable is only used in one module, then you can make it local to that module. The following is a list of input and calculated or assigned variables. Other variables such as loop counters and temporary variables may be needed.
The global static input variables will be the following:
- static double [] cashDonations = new double[6]; //stores the cash donations from 6 sites
- static double [] lbsFood = new double[6]; //stores the pounds of food donated from 6 sites
- static String [] siteName = new String[6]; //stores the names of the 6 sites
The global static calculated or assigned variables will be the following:
- static String bestSiteCash = " "; //stores the site name with the highest cash donation
- static String bestSiteFood = " "; //stores the site name with the highest food donation
- static double totalCash = 0; // stores the total cash collected for all sites
- static double totalFood = 0; //stores the total food pounds collected for all sites
- static double maxFood = 0; //store the highest food collection
- static double maxCash = 0; //stores the highest cash collection
Stage 3: System Design
The following steps will happen in this order in the program:
Methods: Required methods include:
- public static void main(String[] args)
- Should include loop to run the program multiple times
- Should include a call to getDonations( )
- Should include a call to processDonations()
- Should include a call to displayDonations( )
- public static void getDonations()
- Should include a for loop that runs 6 times and includes the following:
- Enter a site name into the array
- Enter cash donation for that site and error code for no negative numbers.
- Enter food donation for that site and error code for no negative numbers.
- public static void processDonations()
- Should set totalCash and totalFood to 0 so that it does not accumulate with multiple runs.
- Should include a for loop that runs 6 times and includes the following:
- A calculation for accumulating totalCash
- A calculation for accumulating totalFood
- Should set maxCash to cashDonations[0]
- Should set maxFood to lbsFood[0]
- Should include a for loop that runs 6 times and includes the following:
- An if statement that determines maxCash and bestSiteCash
- if (cashDonations[i] > maxCash)
{ maxCash = cashDonations[i];
bestSiteCash = siteName[i];
} - An if statement that determines maxFood and bestSiteFood
- if (lbsFood[i] > maxFood)
{ maxFood = lbsFood[i];
bestSiteFood = siteName[i];
} - public static void displayDonations()
- Display Holiday Donations Location Individual report, showing each site name, each cash donation, and each food donation
- Display Holiday Donation Totals report showing the total cash donation and the total food donation.
- Display Holiday Donation Best Site report showing the best location for cash and the highest cash collected, and the best location for food and the highest food pounds collected.
- (see sample output Stage 6 for example reports)
Headers: Program should display appropriate headers to make the output easy to read. See Test Plan output in Stage 5.
Stage 4: Implementation
Coding will be done using the Java language and using the compiler JGrasp
Stage 5: Test Plan
The following sample runs will be used to verify the program meets all requirements and processes properly:
Enter site location name:
Walgreens
Enter cash donations for Walgreens:
198.43
Enter lbs of food donations for Walgreens:
14.54
Enter site location name:
Walmart
Enter cash donations for Walmart:
985.75
Enter lbs of food donations for Walmart:
243.90
Enter site location name:
Meijer
Enter cash donations for Meijer:
1190.50
Enter lbs of food donations for Meijer:
543.76
Enter site location name:
GRCC
Enter cash donations for GRCC:
678.75
Enter lbs of food donations for GRCC:
650.50
Enter site location name:
Shell
Enter cash donations for Shell:
325.75
Enter lbs of food donations for Shell:
12.90
Enter site location name:
Marathon
Enter cash donations for Marathon:
329.43
Enter lbs of food donations for Marathon:
45.36
Holiday Donation Locations Report
------
Site: Walgreens
Individual Cash Donations $198.43
Individual Food Donations 14.54 lbs
Site: Walmart
Individual Cash Donations $985.75
Individual Food Donations 243.90 lbs
Site: Meijer
Individual Cash Donations $1190.50
Individual Food Donations 543.76 lbs
Site: GRCC
Individual Cash Donations $678.75
Individual Food Donations 650.50 lbs
Site: Shell
Individual Cash Donations $325.75
Individual Food Donations 12.90 lbs
Site: Marathon
Individual Cash Donations $329.43
Individual Food Donations 45.36 lbs
Holiday Donation Totals Report
------
Total Cash Donations $3708.61
Total Food Donations 1510.96 lbs
Holiday Donation Best Site Report
------
Best location site for cash donation: Meijer
Max cash collected was $1190.50
Best location site for food donation GRCC
Max food collected was 650.50 lbs
Enter yes if you want to run again:
1