Java help

I need help with this program please,, I need it to print the menu again with the option after viewing the gifts. it in choice 1, also need help with updating the array how do you tak in how many points the user want to buy and add them to the amount of points they already have

import java.util.Scanner;
public class hardwork {

public static void main(String args[]) {

Scanner input = new Scanner (System.in);

int giftpoints[]={2000,1200,700,200,1000};
String gifts[]={"i-pad","PS3","bike","i-pod","L…
int customerpoints[]={500,1200,300};
String names[]={"James","Joe","Danny"};
int pin[]={111,222,333};
int choices=0;
boolean flag=false;
int sub=0, userpin=0;
String strlogin, strpin, stroption;

System.out.print("---- Welcome ----");
System.out.println("\n\nPlease choose an option :\n\n1: Login \n2: Exit\n>");
strlogin=input.next();

while(!strlogin.matches("[1-2]")) {
System.out.println("\nError! 1 or 2 only");
System.out.println("\nPlease choose an option :\n\n1: Login \n2: Exit\n>");
strlogin=input.next();
} //End while
choices=Integer.parseInt(strlogin);
//choices is not valid.

do {

if (choices == 1) {
System.out.print("\nPlease enter Pin: ");
strpin = input.next();
while(!strpin.matches("\\d+")){
System.out.println("Incorrect Pin! ");
System.out.print("\nPlease enter Pin: ");
strpin = input.next();
}
userpin=Integer.parseInt(strpin);

}//end if choice =1
else{
System.out.print("\n\n");
System.exit(0);

}//end else to exit

for(int I = 0; I < pin.length; i++) {
if (userpin == pin[i]) {
flag = true;
sub = i;
break;
}
}//end for password

if (flag == false) {
System.out.println("Incorrect pin!");
}//end if flag is false

} while (flag == false);


System.out.println("\nWelcome : " + names[sub]);
System.out.println("Points : " + customerpoints[sub]);
System.out.println("\n\nPlease choose an option :\n\n1: View Gifts \n2: Buy Gifts\n3: Add Points\n4: Exit\n>");
stroption=input.next();

while (!stroption.matches("[1-4]") ) {
System.out.println("\nError! 1 to 4 only");
System.out.println("\n\nPlease choose an option :\n\n1: View Gifts \n2: Buy Gifts\n3: Add Points\n4: Exit\n>");
stroption=input.next();
}//end while error check
choices=Integer.parseInt(stroption);

if(choices ==1){

System.out.println("\nId \t Gift \t\t Gift Points:");

for (int I = 0; I < gifts.length; i++) {
System.out.println(i+1 + "\t" + gifts[i] + "\t\t\t" + giftpoints[i]);


}//end for

}//end if


else if(choices ==2){

}
else if(choices ==3){
System.out.println("How many Points do you want to buy? ");

}
else{
System.out.print("\n\n");
System.exit(0);

}

}//end main method


}//end class
crowledg
Asked Mar 06, 2013

TIP: If it's not your answer to this question, please click "Leave a Comment" button under the question to communicate with the question owner.

Categories