Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Can you help me to write a Java code for this: The program must satisfy the foll

ID: 654591 • Letter: C

Question

Can you help me to write a Java code for this:

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.

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.

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

Explanation / Answer

import java.util.Scanner;
    public class donations

{
        static double[] cashDonations = new double[6];
                                                      
        static double[] lbsFood = new double[6];
        static String[] siteName = new String[6];
        static String bestSiteCash = " ";                                        
        static String bestSiteFood = " ";                                       
        static double totalCash = 0;
        static double totalFood = 0;
        static double maxFood = 0;
        static double maxCash = 0;

        public static void main(String[] args) {

            Scanner input = new Scanner(System.in);
            String anotherCourse = "yes";
            do {
                getDonations();
                processDonations();
                displayDonations();       
                System.out.print("Enter yes if you want to run again: ");
                anotherCourse = input.next();
                input.nextLine();
                System.out.print(" ");
            } while (anotherCourse.equalsIgnoreCase("yes"));

        }

        public static void getDonations() {
            Scanner input = new Scanner(System.in);        
            for (int i = 0; i < 6; i++) {
                System.out.println("Enter site " + (i + 1) + " name: ");
                siteName[i] = input.next();

                System.out.println("Enter cash donation(USD) for " + siteName[i]
                        + ": ");
                cashDonations[i] = input.nextDouble();          
                System.out.println("Enter food donation(lbs.) for " + siteName[i]
                        + ": ");
                lbsFood[i] = input.nextDouble();

            }

        }

        public static void processDonations()

{
            totalCash = 0;
            totalFood = 0;
            maxCash = cashDonations[0];
            maxFood = lbsFood[0];

            totalCash = cashDonations[1] + cashDonations[2] + cashDonations[3]
                    + cashDonations[4] + cashDonations[5] + cashDonations[6];
            totalFood = lbsFood[1] + lbsFood[1] + lbsFood[2] + lbsFood[3]
                    + lbsFood[4] + lbsFood[5] + lbsFood[6];

        }

        public static void displayDonations() {
            System.out.print("Total Cash Donations are " + totalCash);
            System.out.print("Total Food Donations are " + totalFood);
            System.out.print("Donation totals for " + siteName[1]);
            System.out.print("Total cash: " + cashDonations[1]);
            System.out.print("Food donations " +lbsFood[1]);
            System.out.println();
            System.out.print("Donation totals for " + siteName[2]);
            System.out.print("Total cash: " + cashDonations[2]);
            System.out.print("Food donations " +lbsFood[2]);
            System.out.println();
            System.out.print("Donation totals for " + siteName[3]);
            System.out.print("Total cash: " + cashDonations[3]);
            System.out.print("Food donations " +lbsFood[3]);
            System.out.println();
            System.out.print("Donation totals for " + siteName[4]);
            System.out.print("Total cash: " + cashDonations[4]);
            System.out.print("Food donations " +lbsFood[4]);
            System.out.println();
            System.out.print("Donation totals for " + siteName[5]);
            System.out.print("Total cash: " + cashDonations[5]);
            System.out.print("Food donations " +lbsFood[5]);
            System.out.println();
            System.out.print("Donation totals for " + siteName[6]);
            System.out.print("Total cash: " + cashDonations[6]);
            System.out.print("Food donations " +lbsFood[6]);
            System.out.println();

        }

    }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote