Question: Hello! I just need some help debugging my getNewDep method. Essentially, I am trying to get user to input deposit amount and store this value

Hello! I just need some help debugging my getNewDep method. Essentially, I am trying to get user to input deposit amount and store this value into array DEPOSIT so I can output deposit values and sum of values later. Basically, if user selects to add a new deposit then they should be able to add one value at that time before they are brought back to main menu. I've only ever done this in C++, but I'm having trouble converting the concept to JAVA. All help is appreciated!!!
static String userChoice;
public static void main(String[] args){
final int MAX_DEPS =3;
double[] DEPOSIT = new double[MAX_DEPS];
double count=0;
System.out.println("Hello, please review the menu below and make a selection!");
do {
userChoice = getChoice(userChoice);
switch (userChoice){
case "A":
addNewDep(DEPOSIT, MAX_DEPS, count);
break;
case "V":
depHistory(DEPOSIT, count);
break;
case "E":
System.out.println("You are now exiting the program, have a great day!");
break;
default:
System.out.println("Invalid selection. Please make a valid selection");
break;
}
}while(!userChoice.equals("E"));
}
public static String getChoice(String userChoice){
System.out.println("");
System.out.println("**** MAIN MENU ****");
System.out.println("[A]dd New Deposit");
System.out.println("[V]iew Deposit History");
System.out.println("[E]xit");
System.out.println("");
Scanner choice = new Scanner(System.in);
userChoice = choice.next();
return userChoice;
}
public static void addNewDep(double[] DEPOSIT, int MAX_DEPS, double count){
Scanner sc = new Scanner(System.in);
System.out.println("Please enter in the amount to deposit: ");
double userDeposit = sc.nextDouble();
if(userDeposit >0){
DEPOSIT[count]= userDeposit.nextDouble();
count++;
System.out.println("Deposit successful!");
}
if (userDeposit <0){
System.out.println("Invalid value entered");
return;
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!