0

I'm working on a personal project and one of the features calls for debt information to be gathered. The problem is that for some reason, the array I'm using to store this information starts assigning scanner values to creditValues at 1 instead of 0. It works, but for the sake of simplicity I want it to match the standard 0 index.

public void trackDebt(Scanner scan) {
    int i;
    String userEnters = ""; 
    String[] creditValues = new String[100]; 
    String[] loanValues = new String[100];
    int count1 = 0;
    int count2 = 0;

    //Credit card balances
    System.out.println("Let's get started with you credit card balances");
    System.out.println("Enter your credit card name and the balance owed below. You can enter as many as you'd like, and when you are done type Next to continue");
    
    for (i = 0; i < creditValues.length; i++) {
        userEnters = scan.nextLine();
        if(userEnters.equalsIgnoreCase("next")){ 
            break; 
        }
        else {
            creditValues[i] = userEnters;
            count1 += 1;
        }
    }
Basil Bourque
  • 303,325
  • 100
  • 852
  • 1,154
m119
  • 21
  • 3

0 Answers0