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, 23.06.2019 07:30
What part of the interface displays the external references contained in a selected cell? the status bar the review tab the scroll bar the formula bar
Answers: 1
question
Computers and Technology, 23.06.2019 15:00
Barbara is interested in pursuing a career in the science and math pathway. which qualifications will her reach that goal? a.an advanced knowledge of physics and math b.an advanced knowledge of engineering and math c. an advanced knowledge of physics and robotics an d. advanced knowledge of machinery and math
Answers: 2
question
Computers and Technology, 23.06.2019 20:00
What multimedia system creates an immersive, real-life experience that the user can interact with?
Answers: 1
question
Computers and Technology, 24.06.2019 11:00
Need fast im timed in a paragraph of 125 words, explain at least three ways that engineers explore possible solutions in their projects.
Answers: 2
You know the right answer?
I have a question involving do and for loops while using arrays. // constants
final int NUMBE...
Questions
question
Advanced Placement (AP), 21.05.2021 21:50
question
Mathematics, 21.05.2021 21:50
question
Mathematics, 21.05.2021 21:50
question
Mathematics, 21.05.2021 21:50
question
Mathematics, 21.05.2021 21:50
Questions on the website: 13722361