Question
A school has five classes (called Class 1, Class 2 etc) and they are selling boxes of cookies for a fundraiser. Your program accepts input
A school has five classes (called Class 1, Class 2 etc) and they are selling boxes of cookies for a fundraiser. Your program accepts input (class number followed by number of boxes sold)there are ten lines of input. Method getInput will collect this input and load and return an array of length 5, so that the total number of boxes sold by Class 1 is in the first element, the total for Class 2 is in element 1 etc. Method printOutput then outputs the result.
import java.util.Scanner;
public class L17Num2 {
public static void main(String[] args) { int[] cookiesSold=getInput(); printOutput(cookiesSold); } public static int[] getInput() { //initializations for(int i=0; i<10; i++) { System.out.println("Enter the class(1-5) and the boxes of cookies sold"); //get the input and load up the array }//end for } public static void printOutput(int[]c) { //make sure your output looks like this for each class- no extra words or spaces: //Class 2 sold 4 boxes of cookies. } }
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