1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
mario62 [17]
3 years ago
14

Write a program that lets a maker of chips and salsa keep track of sales for five different types of salsa: mild, medium, sweet,

hot, and zesty. The program should use two parallel 5-element arrays: an array of strings that holds the five salsa names and an array of integers that holds the number of jars sold during the past month for each salsa type. The salsa names should be stored using an initialization list at the time the name array is created. The program should prompt the user to enter the number of jars sold for each type. Once this sales data has been entered, the program should produce a report that displays sales for each salsa type, total sales, and the names of the highest selling and lowest selling products.
Computers and Technology
1 answer:
jok3333 [9.3K]3 years ago
4 0

Answer:

The program in Java is as follows:

import java.util.*;

public class Main{

public static void main(String[] args) {

 Scanner input = new Scanner(System.in);

 String [] salsa = {"Mild","Medium","Sweet","Hot","Zesty"};

 int [] number = new int[5];

 for(int i = 0;i<5;i++){

     System.out.print(salsa[i]+" number: ");

     number[i] = input.nextInt();

 }

 for(int i = 0;i<5;i++){

     System.out.println(salsa[i]+" : "+number[i]);

 }

 int smallest = number[0];  int highest = number[0];

 int count = 0;

 for(int i = 0;i<5;i++){

     if(smallest > number[i]){

         smallest = number[i];

         count = i;

     }

 }

 System.out.println("Smallest");

 System.out.println(salsa[count]+" : "+smallest);

    for(int i = 0;i<5;i++){

     if(highest < number[i]){

         highest = number[i];

         count = i;

     }

 }

 System.out.println("Highest");

 System.out.println(salsa[count]+" : "+highest);

}

}

Explanation:

This initializes the salsa names

 String [] salsa = {"Mild","Medium","Sweet","Hot","Zesty"};

This declares the array for the amount of salsa

 int [] number = new int[5];

This iterates through the 5 salsas and get input for the amount of each

<em>  for(int i = 0;i<5;i++){</em>

<em>      System.out.print(salsa[i]+" number: ");</em>

<em>      number[i] = input.nextInt();</em>

<em>  }</em>

This prints each salsa and the amount sold

<em>  for(int i = 0;i<5;i++){</em>

<em>      System.out.println(salsa[i]+" : "+number[i]);</em>

<em>  }</em>

This initializes smallest and largest to the first array element

 int smallest = number[0];  int highest = number[0];

This initializes the index of the highest or lowest to 0

 int count = 0;

The following iteration gets the smallest of the array elements

<em>  for(int i = 0;i<5;i++){</em>

<em>      if(smallest > number[i]){</em>

<em>          smallest = number[i];</em>

This gets the index of the smallest

<em>          count = i;</em>

<em>      }</em>

<em>  }</em>

This prints the smallest

<em>  System.out.println("Smallest");</em>

<em>  System.out.println(salsa[count]+" : "+smallest);</em>

The following iteration gets the largest of the array elements    

<em>for(int i = 0;i<5;i++){</em>

<em>      if(highest < number[i]){</em>

<em>          highest = number[i];</em>

This gets the index of the highest

<em>          count = i;</em>

<em>      }</em>

<em>  }</em>

This prints the highest

 System.out.println("Highest");

 System.out.println(salsa[count]+" : "+highest);

You might be interested in
Which of the following correctly describes the Filter procedure for managing spreadsheet data? Check all that apply.
saveliy_v [14]

Answer:

Filtering procedure provides an essay and convenient way to visualize or work only with the data we desire without needing to delete those we do not need at that moment.

Filter allows you to view only the information you want to see. Only the required information is displayed at that moment once the filter criteria has been checked.

Filter temporarily hides rows of data that you do not need to view. Rows of data which aren't needed at the moment are temporarily hidden in other to allow user concentrate on the needed data.

Filter allows you to filter text and numeric data. Filtering allows for different filtering criteria, if the user requires working or viewing only on text or numeric data, it is possible with spreadsheet filter.

Explanation:

Filter allows you to view only the information you want to see.

Filter temporarily hides rows of data that you do not need to view

Filter allows you to filter text and numeric data.

5 0
2 years ago
Read 2 more answers
Machine code and Object code is the same right?​
guapka [62]

Answer:

"True" Machine code and Object code is the same.

Explanation:

All code at the same level is considered the same code, so we can say that the machine code, byte code, and the object code with it is of the same type, all of which are considered as the lowest level associated with the common program, these are common. Also known as source code because it is used in translating different languages.

6 0
3 years ago
(01.01 LC)
zloy xaker [14]

Answer:

Create web and mobile applacations

Explanation:

6 0
2 years ago
To place the caption at the top of the image you will need to change the ________
makkiz [27]

wrong!! it was postion!!

4 0
3 years ago
What has happened (or is still happening) to make this speech occur? armageddon
Elodia [21]

Answer:

Are you talking about the bruce willis is superman basically? Because if so i don't think so because that is a future event that hasn't happened yet also that film sucks.

Explanation:

6 0
2 years ago
Other questions:
  • What does Verizon child allow parents to do? My parents recently got the app and put it on my phone so I was wondering...
    11·1 answer
  • Two electronics students are discussing static electricity and electric current. Student A says that a basic property of static
    12·1 answer
  • The Polish mathematician Wacław Sierpiński described the pattern in 1915, but it has appeared in Italian art since the 13th cent
    8·1 answer
  • A type of wireless local area network technology​
    7·2 answers
  • Taken together, the physical and data link layers are called the ____________________. Internet layer Hardware layer Internetwor
    15·1 answer
  • Assume that an array of integers named a that contains exactly five elements has been declared and initialized. Write a single s
    15·1 answer
  • WHAT IS MULTIMEDIA SUPPOSED TO MEAN ???
    15·2 answers
  • Match each term in the second column with its correct definition in the first column. Write the letter of the term on the blank
    12·1 answer
  • Im boing exam help please In a category-based course grading system, teachers weigh a student's performance in all courses. all
    7·2 answers
  • The output of a computer can be seen on ( monitor, keyboard or mouse )​
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!