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, 22.06.2019 18:30
Which of the following is an example of intellectual properly! oa. new version of a novelb. journal of ideasc. pages of a bookood. lines of a poem
Answers: 2
question
Computers and Technology, 23.06.2019 00:30
Which of the following would you find on a network
Answers: 3
question
Computers and Technology, 23.06.2019 22:30
Lakendra finished working on her monthly report. in looking it over, she saw that it had large blocks of white space. what steps could lakendra take to reduce the amount of white space?
Answers: 3
question
Computers and Technology, 24.06.2019 11:00
The program below has been generalized to read a user's input value for hourlywage. run the program. notice the user's input value of 10 is used. modify that input value, and run again. generalize the program to get user input values for workhoursperweek and workweeksperyear (change those variables' initializations to 0). run the program. monthsperyear will never change, so define that variable as final. use the standard for naming final variables. ex: final int max_length
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
Chemistry, 25.07.2019 07:10
question
Spanish, 25.07.2019 07:10
Questions on the website: 13722359