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

You need to store sales for seven differnet types of salsa: mild, medium, hot, s

ID: 3869399 • Letter: Y

Question

You need to store sales for seven differnet types of salsa: mild, medium, hot, sweet, fruit, verde, and zesty. You will need two parallel seven element arrays. An array of strings to hold the salsa names and an array of integers holding the number of jars sold during the past month for each type of salsa. Create a string array, and initialize it with the salsa types. The program should prompt the user to enter the number of jars sold for each type. Use input validation with a loop to ensure that negavie values are not input.

Once the data is input, the program should display a report that shows sales for each salsa type, total sales (total number of jars sold), and the names of the highest and lowest selling products.

Lab hints: When writing this lab, you will need a for loop to enter in the sales numbers and a nested while loop within it to ensure the number entered is greater than 0. After reading in all the sales, you will need another loop that will calculate the total number of jars sold. It will also evaluate the low and high sales. You will need to code something like this to keep track of which index contains the high sales product: if (sales[i] > sales[hiSalesProduct]).

          {

                        hiSalesProduct = i;

             }

You also need to have your program process multiple divers. Put this in an outer loop. After you process the information for one diver, prompt the user if she/he wants to process another diver. Allow the user to type either a Y or y to enter another diver's information; otherwise, exit the loop. Write an event summary by calculating and displaying the average score for all divers and the total number of divers participating.

Garbage in Garbage Out (GIGO): The data being entered by the user needs to be validated. Scores by judges may range between 0 and 10. If the user enters an invalid score, display an error message, and prompt for the score again. Keep doing this until the user enters the score correctly. The degree of difficulty may range from 1.00 to 1.67.

Sample output from program

Jars sold last month of mild: 11

Jars sold last month of medium: 22

Jars sold last month of hot: 33

Jars sold last month of sweet: 44

Jars sold last month of fruit: 55

Jars sold last month of verde: 66

Jars sold last month of zesty: 77

     Salsa Sales Report

Name     Jars Sold

_________________

mild:   11

medium:   22

hot:   33

sweet:   44

fruit:   55

verde:   66

zesty:   77

Total Sales:            308

High Seller: zesty

Low Seller: mild

Press any key to continue.

Step 2: Processing Logic

Using the pseudocode below, write the code that will meet the requirements.

Write report heading

Initialize string array, highest seller index and lowest seller index

Loop

            Input sales for salsa

            Validate to be sure sales are above 0

End-Loop

Loop

            Calculate total jars sold

             Test for low and high sales products

End-Loop

Display the sales for each type of salsa.

Display the total sales, salsa with the highest sales, and the salsa with the lowest sales.

You need to store sales for seven differnet types of salsa: mild, medium, hot, sweet, fruit, verde, and zesty. You will need two parallel seven element arrays. An array of strings to hold the salsa names and an array of integers holding the number of jars sold during the past month for each type of salsa. Create a string array, and initialize it with the salsa types. The program should prompt the user to enter the number of jars sold for each type. Use input validation with a loop to ensure that negavie values are not input.

Once the data is input, the program should display a report that shows sales for each salsa type, total sales (total number of jars sold), and the names of the highest and lowest selling products.

Lab hints: When writing this lab, you will need a for loop to enter in the sales numbers and a nested while loop within it to ensure the number entered is greater than 0. After reading in all the sales, you will need another loop that will calculate the total number of jars sold. It will also evaluate the low and high sales. You will need to code something like this to keep track of which index contains the high sales product: if (sales[i] > sales[hiSalesProduct]).

          {

                        hiSalesProduct = i;

             }

You also need to have your program process multiple divers. Put this in an outer loop. After you process the information for one diver, prompt the user if she/he wants to process another diver. Allow the user to type either a Y or y to enter another diver's information; otherwise, exit the loop. Write an event summary by calculating and displaying the average score for all divers and the total number of divers participating.

Garbage in Garbage Out (GIGO): The data being entered by the user needs to be validated. Scores by judges may range between 0 and 10. If the user enters an invalid score, display an error message, and prompt for the score again. Keep doing this until the user enters the score correctly. The degree of difficulty may range from 1.00 to 1.67.

Sample output from program

Jars sold last month of mild: 11

Jars sold last month of medium: 22

Jars sold last month of hot: 33

Jars sold last month of sweet: 44

Jars sold last month of fruit: 55

Jars sold last month of verde: 66

Jars sold last month of zesty: 77

     Salsa Sales Report

Name     Jars Sold

_________________

mild:   11

medium:   22

hot:   33

sweet:   44

fruit:   55

verde:   66

zesty:   77

Total Sales:            308

High Seller: zesty

Low Seller: mild

Press any key to continue.

Step 2: Processing Logic

Using the pseudocode below, write the code that will meet the requirements.

Write report heading

Initialize string array, highest seller index and lowest seller index

Loop

            Input sales for salsa

            Validate to be sure sales are above 0

End-Loop

Loop

            Calculate total jars sold

             Test for low and high sales products

End-Loop

Display the sales for each type of salsa.

Display the total sales, salsa with the highest sales, and the salsa with the lowest sales.

Explanation / Answer

import java.util.Scanner;

public class JarsCl {

public static void main(String[] args) {

// TODO Auto-generated method stub

String jars[]={"mild","medium","hot","sweat","fruit","verde","zesty"};

int price[]=new int[7];

Scanner sc=new Scanner(System.in);

for(int i=0;i<7;i++)

{

System.out.println("Jars sold last month of "+jars[i]);

price[i]=sc.nextInt();

}

System.out.println(" Salsa Sales Report");

System.out.println("Name Jars Sold ----------------------------- ");

int total=0;

int high=-9999,Low=9999;

int highI=0,LowI=0;

for(int i=0;i<7;i++)

{

System.out.println(jars[i]+" "+price[i]);

total+=price[i];

if(price[i]>high)

{

high=price[i];

highI=i;

}

if(price[i]<Low)

{

Low=price[i];

LowI=i;

}

}

System.out.println("Total Sales: "+total);

System.out.println("High Seller : "+jars[highI]);

System.out.println("Low Seller : "+jars[LowI]);

}

}

============================================================================

Jars sold last month of mild: 11

Jars sold last month of medium: 22

Jars sold last month of hot: 33

Jars sold last month of sweet: 44

Jars sold last month of fruit: 55

Jars sold last month of verde: 66

Jars sold last month of zesty: 77

     Salsa Sales Report

Name     Jars Sold

_________________

mild:   11

medium:   22

hot:   33

sweet:   44

fruit:   55

verde:   66

zesty:   77

Total Sales:            308

High Seller: zesty

Low Seller: mild

Press any key to continue.

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