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]
2 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]2 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
If you receive an email message you suspect is spam, what should you do?
Alla [95]

Answer:

A.  delete the message without opening it.

Explanation:

Never open emails you don't know who sent it, it could be a hacker trying to get your personal/financial information.

6 0
3 years ago
What command embeds a new spreadsheet object at the insertion point?
Debora [2.8K]
The correct answer is A. Table Object > Excel Spreadsheet

 

To be more precise- Click on INSERT on the ribbon tab in Microsoft Office. You will see a button labeled OBJECT. You can then scroll down and pick Excel Spreadsheet in the drop down menu.


6 0
3 years ago
Read 2 more answers
Why were video games invented?
Alenkinab [10]
The answer is in the following website: https://www.reference.com/history/were-video-games-invented-e9413d3dc1378766


4 0
3 years ago
If you created a variable called name, what data type would that value be?
garik1379 [7]

Answer:

a string

Explanation:

bcz that's the only answer

3 0
3 years ago
Read 2 more answers
What format are a setups program file in before executed?
UkoKoshka [18]
.EXE as they are executable programs.  However, it depends on the operating system
6 0
3 years ago
Other questions:
  • What car dealership websites did you use to conduct your research?​
    8·1 answer
  • What is the other name of the horizontal column graph?
    6·2 answers
  • When issued a GFE device, you are required to sign an AUP
    12·2 answers
  • Which network could NOT carry commercial traffic?
    15·1 answer
  • Select the recommended design practice that applies to a web site using images for main site navigation.
    7·1 answer
  • According to the textbook, the definition of transition is
    13·1 answer
  • How do you change the order of the slides in your presentation in the slide pane 
    15·2 answers
  • Define undo and redo​
    12·1 answer
  • Chức năng của hàm MOD(number, divisor)?
    7·1 answer
  • 1. The opportunity to create several equations for launching program files is called
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!