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
An attacker gained remote access to a user's computer by exploiting a vulnerability in a piece of software on the device. The at
Anni [7]

"A Buffer overflow" vulnerability exploit resulted from the attacker's actions.

Whenever a software or an application writes too much data into a buffer, causing neighboring storage regions to have been corrupted as a consequence, this could be determined as Buffer overflow.

⇒ There are two kinds of Buffer overflow attacks such as:

  • <u>Stack-based</u> - It will become more popular to use such memory, as well as that's only available during implementation of any code.
  • <u>Heap-based</u> - Those attacks seem to be more difficult to execute because they entail overflowing overall storage capacity allotted for a program further than the space needed for something like the program's present activities.

Thus we can say that the correct answer is a Buffer overflow.

Learn more about Buffer overflow here:

brainly.com/question/4952591

6 0
2 years ago
6.8 Code Practice<br> please can have some help please
babymother [125]
Sure what is the question though
7 0
3 years ago
A U.S. social security number consists of a string of 9 digits, such as "444422333". Declare a char array named ssn suitable for
tatuchka [14]

Answer:

Since the question expect us to declare a C-string, the solution code is written in C as follows:

  1.    char ssn[9];
  2.    scanf("%s",ssn);

Explanation:

A C-String is a string written in C language. It is an array of characters. To declare a C-string, we use the keyword, <em>char </em>and then followed with the variable name + brackets and the number of characters in the string. For example, we can create a C-String for the SSN number as in Line 1.

To read standard input into the array, we can use C built-in function, <em>scanf(). </em>Just include a string placeholder, %s, and the variable<em> ssn </em>as arguments to <em>scanf()</em>. This will assign the string input by user to variable <em>ssn</em> as C-String.

8 0
3 years ago
How do you measure the capacity of speed and memory of computer system<br>Explain.​
jeka94
Im sorry i just need points
3 0
3 years ago
Is wireless or wired network faster??
bogdanovich [222]

Answer:

Wired

Explanation:

3 0
3 years ago
Read 2 more answers
Other questions:
  • Which statement is true about the elements of the interface of a presentation program? The status bar appears at the top of the
    14·2 answers
  • A network monitor records the following information while recording a network connection.
    9·1 answer
  • What is the function of the capsid? it allows a virus to live independently. it is composed of genetic material. it destroys the
    12·2 answers
  • In file hashing, a file is read by a special algorithm that uses the value of the bits in the file to compute a single number ca
    13·1 answer
  • What feature of a word processing program helps you to easily check and correct spelling mistakes?
    9·1 answer
  • Write a function named "isValidPassword" that takes in a string and returns 1 if it stores a valid password and 0 otherwise, A v
    12·1 answer
  • WHAT THE DEFINITION OD ENGINEER. No CHEAT
    5·2 answers
  • In general, the farther you are from other road users, the A. lower your crash risk B.higher your crash risk C. slower they are
    6·1 answer
  • Modify class Time2 of fig 8.5, (which is split into four pictures) to include a tick method that increments the time stored in a
    8·1 answer
  • Please Help Me!!!!!!!!!!!!!
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!