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
o-na [289]
3 years ago
8

Fix the code so the program will run correctly for MAXCHEESE values of 0 to 20 (inclusive). Note that the value of MAXCHEESE is

set by changing the value in the code itself. If you are not sure of how it should work then look at the Sample Runs of the next part. This part handles the beginning where it lists all the cheese types available and their prices. Note: it is a very simple fix that needs to be added to all the statements that have an array access.
Engineering
1 answer:
GarryVolchara [31]3 years ago
7 0

Answer:

Code fixed below using Java

Explanation:

<u>Error.java </u>

import java.util.Random;

public class Error {

   public static void main(String[] args) {

       final int MAXCHEESE = 10;

       String[] names = new String[MAXCHEESE];

       double[] prices = new double[MAXCHEESE];

       double[] amounts = new double[MAXCHEESE];

       // Three Special Cheeses

       names[0] = "Humboldt Fog";

       prices[0] = 25.00;

       names[1] = "Red Hawk";

       prices[1] = 40.50;

       names[2] = "Teleme";

       prices[2] = 17.25;

       System.out.println("We sell " + MAXCHEESE + " kind of Cheese:");

       System.out.println(names[0] + ": $" + prices[0] + " per pound");

       System.out.println(names[1] + ": $" + prices[1] + " per pound");

       System.out.println(names[2] + ": $" + prices[2] + " per pound");

       Random ranGen = new Random(100);

       // error at initialising i

       // i should be from 0 to MAXCHEESE value

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

           names[i] = "Cheese Type " + (char) ('A' + i);

           prices[i] = ranGen.nextInt(1000) / 100.0;

           amounts[i] = 0;

           System.out.println(names[i] + ": $" + prices[i] + " per pound");

       }        

   }

}

You might be interested in
With 64 KB of memory and 8 bits in each memory location, how wide should the address bus be to access all 64 KB of memory? (k =
marishachu [46]

Answer:

16-bit wide

Explanation:

In order to find the width of the address bus, we need first to know how many memory cells it is needed to address.

If the size memory is 64 KB, this means that the memory size, in bytes, is equal to the following quantity:

64 KB = 2⁶ * 2¹⁰ bytes = 2¹⁶ bytes.

In order to address this quantity of cell positions, the address bus must be able to address 2¹⁶ bytes, so it must have 16-bit wide.

3 0
3 years ago
List two reasons why machined parts often require a high degree of precision.
Gekata [30.6K]

Explanation:

Precision machining is a subtractive process used in cases where material needs to be removed from a raw product to create the finished product. Precision machining can be used to create a wide variety of products, items, and parts for any number of different objects and materials. These parts usually require tight tolerances variation from nominal dimensions and from part to part, which means that there is not much room for error in the production of the piece. Repeatability and well-controlled tolerances are hallmarks of precision machining. Components, parts and finished durable products that are designed to maintain extremely tight tolerance margins and a high degree of durability are essential and common drivers for utilization of precision machining. For example, parts that need to work together as part of a machine may need to always align within a certain margin of 0.01mm to 0.05mm. Precision engineering and machining help to ensure these parts can not only be made precisely but can be produced with this level of accuracy over and over again.

3 0
3 years ago
A large tank is filled to capacity with 500 gallons of pure water. Brine containing 2 pounds of salt per gallon is pumped into t
Nataly [62]

Answer:

A) A(t) = 10(100 - t) + c(100 - t)²

B) Tank will be empty after 100 minutes.

Explanation:

A) The differential equation of this problem is;

dA/dt = R_in - R_out

Where;

R_in is the rate at which salt enters

R_out is the rate at which salt exits

R_in = (concentration of salt in inflow) × (input rate of brine)

We are given;

Concentration of salt in inflow = 2 lb/gal

Input rate of brine = 5 gal/min

Thus;

R_in = 2 × 5 = 10 lb/min

Due to the fact that the solution is pumped out at a faster rate, thus it is reducing at the rate of (5 - 10)gal/min = -5 gal/min

So, after t minutes, there will be (500 - 5t) gallons in the tank

Therefore;

R_out = (concentration of salt in outflow) × (output rate of brine)

R_out = [A(t)/(500 - 5t)]lb/gal × 10 gal/min

R_out = 10A(t)/(500 - 5t) lb/min

So, we substitute the values of R_in and R_out into the Differential equation to get;

dA/dt = 10 - 10A(t)/(500 - 5t)

This simplifies to;

dA/dt = 10 - 2A(t)/(100 - t)

Rearranging, we have;

dA/dt + 2A(t)/(100 - t) = 10

This is a linear differential equation in standard form.

Thus, the integrating factor is;

e^(∫2/(100 - t)) = e^(In(100 - t)^(-2)) = 1/(100 - t)²

Now, let's multiply the differential equation by the integrating factor 1/(100 - t)².

We have;

So, we ;

(1/(100 - t)²)(dA/dt) + 2A(t)/(100 - t)³ = 10/(100 - t)²

Integrating this, we now have;

A(t)/(100 - t)² = ∫10/(100 - t)²

This gives;

A(t)/(100 - t)² = (10/(100 - t)) + c

Multiplying through by (100 - t)²,we have;

A(t) = 10(100 - t) + c(100 - t)²

B) At initial condition, A(0) = 0.

So,0 = 10(100 - 0) + c(100 - 0)²

1000 + 10000c = 0

10000c = -1000

c = -1000/10000

c = -0.1

Thus;

A(t) = 10(100 - t) + -0.1(100 - t)²

A(t) = 1000 - 10t - 0.1(10000 - 200t + t²)

A(t) = 1000 - 10t - 1000 + 20t - 0.1t²

A(t) = 10t - 0.1t²

Tank will be empty when A(t) = 0

So, 0 = 10t - 0.1t²

0.1t² = 10t

Divide both sides by 0.1t to give;

t = 10/0.1

t = 100 minutes

6 0
3 years ago
Line(s) indicates passing is allowed if there are no oncoming cars.
anygoal [31]
Broken yellow b/c you can’t pass on a double solid yellow
5 0
3 years ago
If they opened up the International Space Station to tourism, would you go? Why? answer in 2 sentences
Arlecino [84]
Personally, I would go to the space station. The space station has extreme different levels of technology and abilities, plus who doesn’t want to go to space.
6 0
3 years ago
Read 2 more answers
Other questions:
  • A bar of steel has the minimum properties Se = 40 kpsi, Sy = 60 kpsi, and Sut = 80 kpsi. The bar is subjected to a steady torsio
    7·1 answer
  • A chemistry student accidentally drops a large mercury thermometer and it breaks. The thermometer contained 2 grams of mercury (
    13·1 answer
  • A 220-V electric heater has two heating coils that can be switched such that either coil can be used independently or the two ca
    15·1 answer
  • Let CFG G be the following grammar.
    7·2 answers
  • Ok there..............................................
    6·1 answer
  • Solve the inequality below.Use the drop-down menus to describe the solution and its graph.
    12·1 answer
  • I will mark brainliest.
    6·2 answers
  • Importance of tillage​
    7·1 answer
  • The Imager for Mars Pathfinder (IMP) is an imaging system. It has two camera channels. Each channel has color capability. This i
    7·1 answer
  • Periodic lubrication and oil changes according to manufacturer’s recommendations extend the life of your vehicle, and allow you
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!