subject

I have a question involving do and for loops while using arrays. // constants
final int NUMBER_OF_APPS = 50;
final double SENTINEL_VALUE = -1;

// variables
double[] appPurchasePrice = new double[NUMBER_OF_APPS]; // euro
double appPurchasePriceInput;
int a;

// objects
Scanner keyboardInput = new Scanner(System. in);

// solution
// part 1
a = 0;

do
{
System. out. print("Enter app purchase prices (to stop enter -1): ");
appPurchasePriceInput = keyboardInput. nextDouble();
appPurchasePrice[a] = appPurchasePriceInput;
a++;
}
while(appPurchasePriceInput != SENTINEL_VALUE && a <= NUMBER_OF_APPS);

// part 2
System. out. println();
System. out. println("APP PURCHASE PRICE");

// part 3
for (a = 0; a < appPurchasePrice. length; a = a + 1);
{
System. out. println();
System. out. printf("App Purchase Price: %10.2d%n", appPurchasePrice[a]);
}

I keep getting the error that the array index is out of bounds but I'm confused as to why and I want to know how to fix it.


I have a question involving do and for loops while using arrays.

// constants
final int NUMBER_OF

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 20:50
Write a method in the heapintpriorityqueue class called merge that accepts another heapintpriorityqueue as a parameter and adds all elements from the other queue into the current queue, maintaining proper heap order such that the elements will still come out in ascending order when they are removed. your code should not modify the queue passed in as a parameter. (recall that objects of the same class can access each other's private fields.)
Answers: 2
question
Computers and Technology, 22.06.2019 20:00
Awide variety of “ apps “ are available to customize devices. which category of app does the word processing software fall into?
Answers: 2
question
Computers and Technology, 23.06.2019 01:00
Complete the sentence about a presentation delivery method
Answers: 2
question
Computers and Technology, 23.06.2019 16:00
Which analyst position analyzes information using mathematical models to business managers make decisions?
Answers: 1
You know the right answer?
I have a question involving do and for loops while using arrays. // constants
final int NUMBE...
Questions
question
Mathematics, 22.09.2021 23:40
question
History, 22.09.2021 23:50
Questions on the website: 13722367