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]
4 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]4 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
A program contains the following function definition: int cube(int number) { return number * number * number; } Write a stateme
Nonamiya [84]

Answer:

The statement can be written as

int result = cube(4);

Explanation:

A function is a block of reusable codes to perform some tasks. For example, the function in the question is to calculate the cube of a number.

A function can also operate on one or more input value (argument) and return a result. The <em>cube </em>function in the question accept one input value through its parameter <em>number </em>and the <em>number</em> will be multiplied by itself twice and return the result.  

To call a function, just simply write the function name followed with parenthesis (e.g. <em>cube()</em>). Within the parenthesis, we can include zero or one or more than one values as argument(s) (e.g. <em>cube(4)</em>).

We can then use the "=" operator to assign the return output of the function to a variable (e.g. <em>int result = cube(4)</em>)

8 0
4 years ago
Free brainlist because im new and i just want to but you have t friend me first
Amiraneli [1.4K]
Okay sure.









I’ll 1)chords
2)pulse
3)aerophone
4) the answer is C
5)rhythm

Pretty sure those are the answers
4 0
3 years ago
For an Otto cycle, plot the cycle efficiency as a function of compression ratio from 4 to 16.
Elza [17]

Assumptions:

  • Steady state.
  • Air as working fluid.
  • Ideal gas.
  • Reversible process.
  • Ideal Otto Cycle.

Explanation:

Otto cycle is a thermodynamic cycle widely used in automobile engines, in which an amount of gas (air) experiences changes of pressure, temperature, volume, addition of heat, and removal of heat. The cycle is composed by (following the P-V diagram):

  • Intake <em>0-1</em>: the mass of working fluid is drawn into the piston at a constant pressure.
  • Adiabatic compression <em>1-2</em>: the mass of working fluid is compressed isentropically from State 1 to State 2 through compression ratio (r).

        r =\frac{V_1}{V_2}

  • Ignition 2-3: the volume remains constant while heat is added to the mass of gas.
  • Expansion 3-4: the working fluid does work on the piston due to the high pressure within it, thus the working fluid reaches the maximum volume through the compression ratio.

         r = \frac{V_4}{V_3} = \frac{V_1}{V_2}

  • Heat Rejection 4-1: heat is removed from the working fluid as the pressure drops instantaneously.
  • Exhaust 1-0: the working fluid is vented to the atmosphere.

If the system produces enough work, the automobile and its occupants will propel. On the other hand, the efficiency of the Otto Cycle is defined as follows:

           \eta = 1-(\frac{1}{r^{\gamma - 1} } )

where:

           \gamma = \frac{C_{p} }{C_{v}} : specific heat ratio

Ideal air is the working fluid, as stated before, for which its specific heat ratio can be considered constant.

           \gamma = 1.4

Answer:

See image attached.

5 0
3 years ago
3. A 4-m × 5-m × 7-m room is heated by the radiator of a steam-heating system. The steam radiator transfers heat at a rate of 10
Natali [406]

Answer:

14.52 minutes

<u>OR</u>

14 minutes and 31 seconds

Explanation:

Let's first start by mentioning the specific heat of air at constant volume. We consider constant volume and NOT constant pressure because the volume of the room remains constant while pressure may vary.

Specific heat at constant volume at 27°C = 0.718 kJ/kg*K

Initial temperature of room (in kelvin) = 283.15 K

Final temperature (required) of room = 293.15 K

Mass of air in room= volume * density= (4 * 5 * 7) * (1.204 kg/m3) = 168.56kg

Heat required at constant volume: 0.718 * (change in temp) * (mass of air)

Heat required = 0.718 * (293.15 - 283.15) * (168.56) = 1,210.26 kJ

Time taken for temperature rise: heat required / (rate of heat change)

Where rate of heat change = 10000 - 5000 = 5000 kJ/hr

Time taken = 1210.26 / 5000 = 0.24205 hours

Converted to minutes = 0.24205 * 60 = 14.52 minutes

4 0
4 years ago
3. Which of these instruments is used to measure wind speed? A. anemometer C. wind sock B. thermometer D. wind vane It is an ins
siniylev [52]

Answer:

wind vane if it can be used to show wind speed and the other is a

Explanation:

please mark 5 star if im right and brainly when ya can

5 0
3 years ago
Other questions:
  • Which statement best describes how a hearing aid works?
    7·1 answer
  • A high-voltage direct-current (dc) transmission line between Celilo, Oregon and Sylmar, California is 845 mi in length. The line
    15·1 answer
  • What is the steady-state value of the output of a system with transfer function G(s)= 6/(12s+3), subject to a unit-step input?
    5·1 answer
  • A thick spherical pressure vessel of inner radius 150 mm is subjected to maximum an internal pressure of 80 MPa. Calculate its w
    9·1 answer
  • -0-1"<br> -0<br> -20<br> -15<br> -10<br> 0<br> -5
    9·1 answer
  • Engineers need to be open-ended when dealing with their designs. Why?
    11·1 answer
  • What are the potential hazards relating to materials handling injuries?
    6·1 answer
  • 6.) ___________ is a disadvantage of local storage since it can be very expensive.
    5·1 answer
  • Technician A says that if fuel pump pressure is correct, fuel pump volume will be correct as well. Technician B says that a fuel
    15·1 answer
  • Planetary gears require the armature to be offset via a gear housing that holds the starter drive.
    12·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!