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
Need help with this please and thanks
Kryger [21]

Answer:

<h3>Connector names are written below Picture vise:</h3>
  • USB-C
  • USB 2.0
  • Micro USB
<h3 />

Explanation:

Following is the brie Illustration of the terms used:

  • USB-C:

              It is the newest connector in the market with the             reversible/symmetrical design. It can be adapted to work with the legacy connectors such as USB-A, USB-B, USB-C and Micro USB.

  • USB 2.0:

              It is used mostly in the connections of electronic devices such as printers and smartphones. It has A to B connectors as well as micro USB connectors and mini USB connectors.

  • Micro USB:

              It is used for the connection o compact devices such as smartphone and mp3 players. They are further grouped into three categories: Micro A, Micro B and micro USB 3.

<h3>I hope it will help you!</h3>
7 0
2 years ago
SHOW ALL YOUR WORK. REMEMBER THAT PROGRAM SEGMENTS ARE TO BE WRITTEN IN JAVA. Assume that the classes listed in the Java Quick R
Ne4ueva [31]

Answer:

Check the explanation

Explanation:

CODE:-

import java.util.*;

class UserName{

  ArrayList<String> possibleNames;

  UserName(String firstName, String lastName){

      if(this.isValidName(firstName) && this.isValidName(lastName)){

          possibleNames = new ArrayList<String>();

          for(int i=1;i<firstName.length()+1;i++){

              possibleNames.add(lastName+firstName.substring(0,i));

          }  

      }else{

          System.out.println("firstName and lastName must contain letters only.");

      }

  }

  public boolean isUsed(String name, String[] arr){

      for(int i=0;i<arr.length;i++){

          if(name.equals(arr[i]))

              return true;

      }

      return false;

  }

  public void setAvailableUserNames(String[] usedNames){

      String[] names = new String[this.possibleNames.size()];

      names = this.possibleNames.toArray(names);

      for(int i=0;i<usedNames.length;i++){

          if(isUsed(usedNames[i],names)){

              int index = this.possibleNames.indexOf(usedNames[i]);

              this.possibleNames.remove(index);

              names = new String[this.possibleNames.size()];

              names = this.possibleNames.toArray(names);

          }

      }

  }

  public boolean isValidName(String str){

      if(str.length()==0) return false;

      for(int i=0;i<str.length();i++){

          if(str.charAt(i)<'a'||str.charAt(i)>'z' && (str.charAt(i)<'A' || str.charAt(i)>'Z'))

              return false;

      }

      return true;

  }

  public static void main(String[] args) {

      UserName person1 = new UserName("john","smith");

      System.out.println(person1.possibleNames);

      String[] used = {"harta","hartm","harty"};

      UserName person2 = new UserName("mary","hart");

      System.out.println("possibleNames before removing: "+person2.possibleNames);

      person2.setAvailableUserNames(used);

      System.out.println("possibleNames after removing: "+person2.possibleNames);

  }

}

Kindly check the attached image below for the code output.

5 0
3 years ago
 What should every Software Engineer know about Software Architecture? ”<br> ??
Llana [10]
<span>Answer: -Software architecture isn't about big design up front; -Every software team needs to consider software architecture; -The software architecture role is about coding, coaching and collaboration; -You don't need to use UML; -A good software architecture enables agility.</span>
7 0
2 years ago
Which of the following kinds of software is a sophisticated type of application software that assists a professional user in cre
Setler [38]

Answer:

The answer is A. CAD which means Computer-Aided Design.

Explanation:

CAD is used for creating different designs, simulations and scientific diagrams, some examples of CAD software include AutoCAD and Solidworks.

For reference the other acronyms mean:

Desktop publishing (DTP)

Computer-based training (CBT)

Web-based training (WBT)

4 0
2 years ago
You are installing windows on a new computer. Using the RAID controller on the motherboard, you configure three hard disks in a
Sergio [31]

Answer:

On the screen where you select the disk to install Windows, click "Load Driver"

Explanation:

While the user has Windows installed on a new system. Instead, he configures several hard disks in such a RAID 5 series using the RAID controller onto the motherboard. The user is left unpartitioned and improperly formatted in the list. He edits that boot request from either the optical drive for the BIOS to boot. He installs DVD drive, begins the configuration, and boots to the disk.

Then press the "Load Driver" button on the monitor where he picks the disk to install Windows

7 0
2 years ago
Other questions:
  • I want to work on cloud computing and i need some help on how to start ?
    6·1 answer
  • Which of these jobs would be most appropriate for someone who majors in computer engineering? I need the answer ASAP Helping com
    14·2 answers
  • What is the purpose for the refresh button?
    10·2 answers
  • When you want to avoid sending email that a recipient may feel their privacy has been invaded, how would you fill in the (To) bo
    13·1 answer
  • ___________________ are aggregated collections of memory and cpu resources that can be shared among groups of virtual machines o
    11·1 answer
  • Write a program that prompts the user to enter a point (x, y) and checks whether the point is within the rectangle centered at (
    12·1 answer
  • Define Agricultural Era
    14·2 answers
  • What number will be output by the console.log command on line 5?
    9·1 answer
  • An IT department receives a shipment of 20 new computers, and Alice has been assigned the task of preparing them for deployment
    12·1 answer
  • Types of digital divide ​
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!