CO116 Final Project Holiday Donation Drive Program Solution

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:
1. 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?

2. 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.

3. 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:
1. In order to calculate the total cash donation and total food donation, use accumulation.

2. 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:
1. static double [] cashDonations = new double[6]; //stores the cash donations from 6 sites
2. static double [] lbsFood = new double[6]; //stores the pounds of food donated from 6 sites
3. static String [] siteName = new String[6]; //stores the names of the 6 sites
The global static calculated or assigned variables will be the following:
1. static String bestSiteCash = " "; //stores the site name with the highest cash donation
2. static String bestSiteFood = " "; //stores the site name with the highest food donation
3. static double totalCash = 0; // stores the total cash collected for all sites
4. static double totalFood = 0; //stores the total food pounds collected for all sites
5. static double maxFood = 0; //store the highest food collection
6. 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:
1. public static void main(String[] args)
a. Should include loop to run the program multiple times
b. Should include a call to getDonations( )
c. Should include a call to processDonations()
d. Should include a call to displayDonations( )
2. public static void getDonations()
a. Should include a for loop that runs 6 times and includes the following:
i. Enter a site name into the array
ii. Enter cash donation for that site and error code for no negative numbers.
iii. Enter food donation for that site and error code for no negative numbers.
3. public static void processDonations()
a. Should set totalCash and totalFood to 0 so that it does not accumulate with multiple runs.
b. Should include a for loop that runs 6 times and includes the following:
i. A calculation for accumulating totalCash
ii. A calculation for accumulating totalFood
c. Should set maxCash to cashDonations[0]
d. Should set maxFood to lbsFood[0]
e. Should include a for loop that runs 6 times and includes the following:
i. An if statement that determines maxCash and bestSiteCash
1. if (cashDonations[i] maxCash)
{ maxCash = cashDonations[i];
bestSiteCash = siteName[i];
}
ii. An if statement that determines maxFood and bestSiteFood
1. if (lbsFood[i] maxFood)
{ maxFood = lbsFood[i];
bestSiteFood = siteName[i];
}
4. public static void displayDonations()
a. Display Holiday Donations Location Individual report, showing each site name, each cash donation, and each food donation
b. Display Holiday Donation Totals report showing the total cash donation and the total food donation.
c. 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.
d. (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:
Powered by