Program Review Table
Program Review Table
3
switch(choice) // Line 48
choices { This is an example of a switch
case'1': displayStocks(); break; statement I used to allow the user
case'2': buyShares(); break; to choose the feature they wanted
case'3': sellShares(); break;
to use. Each case links to a
case'4': repriceShare(); break;
case'5': totalValue(); break;
method which was written later
case'6': break; down the code.
default: System.out.println("Options 1-6 only please.");
}
4
switch(choice)
input validation { In this do while loop, I used the
case'1': displayStocks(); break; switch statement which gave the
case'2': buyShares(); break; user a choice. But in a scenario in
case'3': sellShares(); break;
which the user doesn’t give the
case'4': repriceShare(); break;
case'5': totalValue(); break;
correct input – I used the ‘default:’
case'6': break; function to display a message to
default: System.out.println("Options 1-6 only please."); the user to enter in from the correct
} range.
}while(choice != '6');
5
static Stock[] stocks = new Stock[5]; // Line 6
arrays An array I used to store all 5
stocks[0] = apple; // Line 21 stocks. I declared the array in line
stocks[1] = microsoft; 6 and made it static so its visible to
stocks[2] = tesla;
the whole code.
stocks[3] = amazon;
stocks[4] = accenture;
From line 21, I added each stock to
a location in the array individualy.
6
7