answer.
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]
2 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]2 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
Your roommate wants to learn about organizational chart. You can tell her that these charts can tell you all of these about an o
mars1129 [50]

Answer:

Control mechanisms

Explanation:

Organizational chart of any company will give details of different aspects of the company such as the major sub-units of the organization with the names of team leaders for different sub-units, it can also give you the span of control and the division of work within the company. However, the chart can't show you control mechanisms of different departments.

4 0
2 years ago
A plate of an alloy steel has a plane-strain fracture toughness of 50 MPa√m. If it is known that the largest surface crack is 0.
Ivahew [28]

Answer:

option B is correct. Fracture will definitely not occur

Explanation:

The formula for fracture toughness is given by;

K_ic = σY√πa

Where,

σ is the applied stress

Y is the dimensionless parameter

a is the crack length.

Let's make σ the subject

So,

σ = [K_ic/Y√πa]

Plugging in the relevant values;

σ = [50/(1.1√π*(0.5 x 10^(-3))]

σ = 1147 MPa

Thus, the material can withstand a stress of 1147 MPa

So, if tensile stress of 1000 MPa is applied, fracture will not occur because the material can withstand a higher stress of 1147 MPa before it fractures. So option B is correct.

8 0
2 years ago
. A cylindrical metal specimen having an original diameter of 12.8 mm (0.505 in.) and gauge length of 50.80 mm (2.000 in.) is pu
kogti [31]

Answer:

% reduction in area==PR=0.734=73.4%

% elongation=EL=0.42=42%

Explanation:

given do=12.8 mm

df=6.60

Lf=72.4 mm

Lo=50.8 mm

% reduction in area=((\pi*(do/2)^2)-(\pi*(df/2)^2)))/\pi*(do/2)^2

substitute values

% reduction in area=73.4%

% elongation=EL=((Lf-Lo)/Lo))*100

% elongation=((72.4-50. 8)/50.8)*100=42%

6 0
2 years ago
Explain why the fundamental software engineering principles of process, dependability, requirements management, and reuse are re
Svet_ta [14]

Answer:

1. Costs and frequency of change.

2. The most important ‘non-functional’ requirements. Different systems have different priorities for non-functional requirements.

3. The software lifetime and delivery schedule.

Explanation:

The process of requirement gathering is required in both generic and customized software.

• A document to define the development process is required in all type of software application.

• Updating is required in each type of software. For doing so, new version of each type of software is released.

• Maintenance is an important part of software development. It is required in each type of application development.

• Software has some minimum requirements to execute. So, platform dependability is considered in all software development.

5 0
2 years ago
Read 2 more answers
CHALLENGE ACTIVITY 1.4.1: Basic syntax errors. Type the statements. Then, correct the one syntax error in each statement. Hints:
Lunna [17]

Answer:

Lets check each statement for the errors.

Explanation:

System.out.println("Predictions are hard.");

This statement has no syntax errors. When this statement is executed the following line will be displayed:

Predictions are hard.

System.out.print("Especially ');

This statement is missing the closing quotation mark. A single quotation mark is placed instead of double quotation mark in the statement.

The following error message will be displayed when this program statement will be compiled:

Main.java:15: error: unclosed string literal

String literals use double quotes. So to correct this syntax error, the statement should be changed as follows:

System.out.print("Especially");

The output of this corrected line is as following:

Especially

System.out.println("about the future.").

In this line a period . is placed at the end of the statement instead of a semicolon ; but according to the syntax rules statements should end in semicolons.

The error message displayed when this line is compiled is as following:

Main.java:15: error: ; expected

Main.java:15: error: not a statement

So in order to correct this syntax error the statement should be changed as following:

System.out.println("about the future.");    

The output of this corrected line is as following:

about the future

System.out.println("Num is: " - userName);

There is a syntax error in this statement because of - symbol used instead of +

+ symbol is used to join together a variable and a value a variable and another variable in a single print statement.

The error message displayed when this line is compiled is as following:

Main.java:13: error: bad operand types for binary operator '-'

So in order to correct this syntax error the statement should be changed as following:

System.out.println("Num is: " + userName);

This line will print two things one is the string Num is and the other is the value stored in userName variable.

So let userName= 5 then the output of this corrected line is as following:

Num is: 5

8 0
2 years ago
Other questions:
  • Define a) Principal Plane b) Principal Stress c) anelasticity d) yield point e) ultimate tensile stress f) hardness g) toughness
    5·1 answer
  • A square loop of wire surrounds a solenoid. The side of the square is 0.1 m, while the radius of the solenoid is 0.025 m. The sq
    6·1 answer
  • Some states have osha programs, but you should always defer to the federal program.
    8·2 answers
  • What is the PW (at i 5%) of SuperTool's new test equipment? The development cost is $1.2M. Net revenues will begin at $300,000 f
    9·1 answer
  • Technician A says that the most efficient method of EVAP system leak detection is introducing smoke under low pressure from a ma
    7·1 answer
  • In this module you learned about searching, sorting and algorithms in C++ and how to implement these elements in your C++ progra
    6·1 answer
  • The velocity distribution for laminar flow between parallel plates is given by u umax = 1 − ( 2y h ) 2 Where h is the distance s
    15·1 answer
  • When comparing solids to fluids, the following is true: for elastic solids, the stress must be normal. For Newtonian fluids, the
    9·1 answer
  • technician A says that in any circuit, electrical current takes the path of least resistance. technician B says that while this
    13·1 answer
  • Mr. Ray deposited $200,000 in the Old and Third National Bank. If the bank pays 8% interest, how much will he have in the accoun
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!