I am just messing around with some exercises in a book for a Java summer class because I am a little ahead, meaning this is not homework. I'm getting an error message stating you cannot convert from String to int but both are Strings, one is a variable and one an Array.
It's this line I'm having trouble with... select = items[select];
public class CarpentryChoice {
public static void main(String[] args) {
String items [] = {"Table", "Desk", "Chair", "Couch", "Lazyboy"};
int price [] = {250, 175, 125, 345, 850};
String select;
Scanner scan = new Scanner(System.in);
System.out.println("Please enter an item to view it's price: ");
select = scan.nextLine();
for(int i=0; i < items.length; i++) {
select = items[select];
}
}
}
select = items[select]isn't want you want, since arrays require an integer index.