javaProject1 - if(nameValid > -1) { correctName...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
Sheet1 Page 1 import java.util.* public class Login { public static void main(String[] s) { String[] accountInfs = {"aagusto_6497", "rblaquiere_6940", "dbrindou_8239", cchristiansen_7653, "sciufo_5097", "bcosta_0233", "zcoursen_7205", "jdegaitas_8056", mferreira_3832, "kharrison_5545", "kjaramillo_3572", "jmarra_0306u", "dmedeiros_6587", "apaul_0303", jereyes_8415, "arichards_6535", "jsalisbury_1408", "hwu_8229"} String[] names = new String[accountInfs.length] String[] codes = new String[accountInfs.length] int nameValid = 0 Scanner kbd = new Scanner(System.in) String accountName, accountCode Boolean correctName = false Boolean correctPassword = false int count = 0 System.out.printf("Enter your account name: " ) accountName = kbd.nextLine() nameValid = findIndex(accountInfs, accountName)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: if(nameValid > -1) { correctName = true } else { count++ } } if(correctName){ count = 0 while(!correctPassword && count < 3){ System.out.printf("Enter your account code: ") accountCode = kbd.nextLine() String validPassword = accountInfs[nameValid].split("_")[1] if(accountCode.equals(validPassword)){ correctPassword = true } else{ count++ } } } Sheet1 Page 2 if(correctPassword) { System.out.printf("Welcome!") }else { System.out.printf("Login Failed!") } } public static int findIndex(String accountInfs, String name) { for(int index=0 String validName = accountInfs[index].split("_")[0] if(validName.equals(name)) { return index } } return -1 } } Sheet1 Page 3 Sheet1 Page 4 index<accountInfs.length index++){...
View Full Document

This note was uploaded on 04/17/2008 for the course CS 221 taught by Professor Drzhou during the Spring '08 term at Rhode Island College.

Page1 / 4

javaProject1 - if(nameValid > -1) { correctName...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online