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
Assoli18 [71]
3 years ago
12

Write a short program that uses a for loop to populate an array. The array can store up to 10 integers. Modify the code slightly

to create a bug that would prevent the code from compiling or even better from running correctly. Be sure to describe what the code is designed to do. Monitor the post to comment when other students work to repair your code.
Computers and Technology
1 answer:
mr Goodwill [35]3 years ago
8 0

Answer:

  1. public class num16 {
  2.    public static void main(String[] args) {
  3.        //This code is designed to create and populate an array with
  4.        //Ten Integer values
  5.        Scanner in = new Scanner(System.in);
  6.        //Create the array
  7.        int [] intArray = new int [10];
  8.        //populating the array
  9.        for(int i =0; i<=10; i++){
  10.            System.out.print("Enter the elements: ");
  11.            intArray[i]= in.nextInt();
  12.        }
  13.        //Print the Values in the array
  14.        System.out.println(Arrays.toString(intArray));
  15.    }
  16. }

Explanation:

  • The above code looks like it will run successfully and give desired output.
  • But a bug has been introduced on line 9. This will lead to an exception called ArrayIndexOutOfBoundsException.
  • The reason for this is since the array is of length 10, creating a for loop from 0-10 will amount to 11 values, and the attempt to access index 10 for the eleventh element will be illegal
  • One way to fix this bug is to change the for statement to start at 1.
You might be interested in
If you are trying to improve your budget and spending, which option would save you the most money?
Solnce55 [7]

Explanation:

If you want to improve your budget and spending, then the best option that would save you the most money would be buying the securities for a long period of time on fixed basis. This will allow you to hold your savings with the bank, and you won't be able to take them out easily before the term period. In this way you won't think of spending that money. Also you can have an interest amount earned on these securities. In this way you can save the most money.

8 0
3 years ago
Read 2 more answers
Fuction table of JK-Flip flop?
vivado [14]

Answer:

Explanation:

The Truth Table for the JK Function. Then the JK flip-flop is basically an SR flip flop with feedback which enables only one of its two input terminals, either SET or RESET to be active at any one time thereby eliminating the invalid condition seen previously in the SR flip flop circuit.

6 0
3 years ago
16 POINTS
Nostrana [21]
It think it's a Nested List.
Im so sorry if this is wrong
6 0
3 years ago
The central computer on a network is called the ______. A) boss B) client C) parent D) server
KiRa [710]

Answer: The central computer on a network is called :

A Server.

Explanation: Server is a program that provides services to other programs or devices either on the same computer or over a computer network.

5 0
4 years ago
Read 2 more answers
Your assignment is to write an assembly language program which read a string and print it in uppercase. This program asks the us
const2013 [10]

Answer:

try this

Explanation:

MSG1 DB 10,13,'enter any string:-$'

MSG2 DB 10,13,'converted string is:-$'

P1 LABEL BYTE

M1 DB 0FFH

L1 DB?

P11 DB 0FFH DUP<'$'>

DATA ENDS

DISPLAY MARCO MSG

MOV AH,9

LEA DX,MSG

INT 21H

ENDM

CODE SEGMENT

ASSUME CS: CODE,DS:DATA

START:

MOV AX,DATA

MOV DS,AX

DISPLAY MSG1

LEA DX,P1

MOV AH,0AH

INT 21H

DISPLAY MSG2

LEA SI,P1

MOV CL,L1

MOV CH,0

CHECK:

CMP[SI],61H

JB DONE

CMP[SI],5BH

UPR: SUB[SI],20H

DONE: INC SI

LOOP CHECK

DISPLAY P11

MOV AH,4CH

INT 21H

CODE ENDS

END START

4 0
3 years ago
Other questions:
  • Which of the following is not a standard method called as partof the JSP life cycle?
    5·1 answer
  • Citing the recent increase in earnings by several computer companies, economists feel that a cycle has begun in which personal c
    13·1 answer
  • Send the memes whoever is the best will get that crown thing lol
    10·2 answers
  • In a company you are in charge of system maintainance. Justify with 5 reasons why your role is key
    6·1 answer
  • List three examples of telescopes that detect different types of electromagnetic radiation?
    11·1 answer
  • Give your definition of a stored procedure. Based on the Academic Database, identify and describe a scenario where it would be n
    12·1 answer
  • What should you include in a persuasive speech
    14·1 answer
  • 1. Pasar los siguientes ejercicios a diagrama de bloque
    11·1 answer
  • 6.1.5: Function definition: Volume of a pyramid.
    8·1 answer
  • Cycle technology implemented a dibs initiative last year for one of the manufacturing sites. however, the initiative is not prog
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!