Question
One Girl Scout troop has three volunteer leaders. Each leader is a mentor for a portion of the scouts in the troop. The scouts are
One Girl Scout troop has three volunteer leaders. Each leader is a mentor for a portion of the scouts in the troop. The scouts are selling Girl Scout cookies for $2.75 per box. The maximum number of cookies that any one scout can sell is 100 boxes. The troop would like to know the average number of boxes sold across the entire troop. They would also like to know which leader is mentoring the scout that sold the most boxes of cookies. (Note do not put in extra code to work with ties between numbers of boxes of cookies. Choose one name of the tied leaders as the winner.) Another statistic that they would like to determine is the number of scouts that each leader mentors that has more than the average number of boxes sold. Finally the troop wants to know the total money collected by each mentor as well as the total money collected by the troop.
The user of this program will enter the names of the troop leaders as well as the number of scouts mentored by each leader. They will also be able to choose between two options of determining the number of boxes of cookies sold by each scout. The first option will allow the number of boxes of cookies sold by each scout to be entered at the keyboard. The second option will allow the number of boxes of cookies sold by each scout to be chosen randomly.
Here is the code so far
package arrayPracticePackage;
import java.util.Scanner;
public class ReturnArray
{
public static void main(String[] args)
{
int cntr;
for(cntr = 0; cntr < 3; ++cntr)
{
handleTroop();
}
}
public static void handleTroop()
{
Scanner input = new Scanner(System.in);
int scoutNumber = 0;
int cookieBox = 0;
System.out.println("Please enter number of scouts in troop\t");
scoutNumber = input.nextInt();
int[] scoutArray = new int[scoutNumber];
for(int i = 0; i < scoutArray.length; ++i)
{
System.out.println("Enter cookie boxes sold\t");
cookieBox = input.nextInt();
scoutArray[i] = cookieBox;
}
for(int i = 0; i < scoutArray.length; ++i)
{
System.out.println(i + "\t\t"+ scoutArray[i]);
}
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started