Results 1 to 9 of 9
  1. #1
    seanfmglobal is offline Member
    Join Date
    Nov 2010
    Posts
    40
    Rep Power
    0

    Default Array's not being found.

    Sorry for so many post's. I wish I could give back but unfortunately I'm not experienced enough to give good advice. Anyway can't figure out why my array's are not being found. Any help would be great full. This program is not finished but I am kind of stumped on this part. Please any suggestions also would be very grateful.

    Java Code:
    import java.lang.String;
    import java.util.Scanner;
    public class ATM	{
    	public static void main(String[] args)	{
    	Scanner input = new Scanner(System.in);
    	
    		System.out.printf("%s\n%s\n%s\n%s\n%s\n\n\n",
    		"*  *  *****  *      *      *****",
    		"*  *  *      *      *      *   *",
    		"****  *****  *      *      *   *",
    		"*  *  *      *      *      *   *",
    		"*  *  *****  *****  *****  *****");
    		System.out.printf("%s\n%s\n%s\n%s\n%s\n\n\n",
    		"*     *  *****  *      *****  *****  *******  *****        *****  *****",
    		"*     *  *      *      *      *   *  *  *  *  *              *    *   *",
    		"*     *  *****  *      *      *   *  *     *  *****          *    *   *",
    		"*  *  *  *      *      *      *   *  *     *  *              *    *   *",
    		"*******  *****  *****  *****  *****  *     *  *****          *    *****");
    		System.out.printf("%s\n%s\n%s\n%s\n%s\n\n\n",
    		"*****  ****    ***   *   *  *   *",
    		"  *    *   *  *   *  **  *  *  *",
    		"  *    ****   *****  * * *  ***",
    		"  *    *   *  *   *  *  **  *  *",
    		"*****  ****   *   *  *   *  *   *");
    		
    			
    		int[] amounts;          //amounts in each account
    		amounts = new int[10];      //declares 10 spots for integers
    		
    		amounts[0] = 1793;
    		amounts[1] = 738;
    		amounts[2] = 403;
    		amounts[3] = 9834;
    		amounts[4] = 340;
    		amounts[5] = 4600;
    		amounts[6] = 760;
    		amounts[7] = 640;
    		amounts[8] = 9040;
    		amounts[9] = 1030;
    		
    		int[] savamounts;		//savings amounts
    		savamounts = new int[10];	//declare's 10 for int
    		
    		savamounts[0] = 534;
    		savamounts[1] = 346;
    		savamounts[2] = 6744;
    		savamounts[3] = 3456;
    		savamounts[4] = 376;
    		savamounts[5] = 453;
    		savamounts[6] = 932;
    		savamounts[7] = 349;
    		savamounts[8] = 903;
    		savamounts[9] = 394;
    		
    		
    		String Account_Number; //Var that holds the account number
    		int Pin; //Var that holds pin number to spec account
    		
    		System.out.println("Account Number: ");
    		Account_Number = input.next();
    		
    		System.out.println("Pin: ");
    		Pin = input.nextInt();
    		int counter = 0;
    		if (Account_Number == "175392" && Pin == 9090)	{
    			sean();	}	else if (Account_Number == "153926" && Pin == 8887)	{
    			nic();	}	else if (Account_Number == "173944" && Pin == 4392)	{
    			jo();	}	else if (Account_Number == "174796" && Pin == 6869)	{
    			bean();	}	else if (Account_Number == "148953" && Pin == 3245)	{
    			bj();	}	else if (Account_Number == "195348" && Pin == 4238)	{
    			sarah();	}	else if (Account_Number == "165332" && Pin == 9768)	{
    			reg();	}	else if (Account_Number == "134987" && Pin == 5459)	{
    			tra();	}	else if (Account_Number == "192462" && Pin == 6668)	{
    			mon();	}	else if (Account_Number == "133689" && Pin == 4422)	{
    			les();	}	else { 
    				System.out.println("Information is Invalid... ");
    				int test = input.nextInt();
    				System.exit();
    			}
    	}
    			
    			public static void sean()	{
    				Scanner option = new Scanner(System.in);
    				int selection;
    				
    				System.out.printf("%s\n%s\n%s\n&s\n%s\n\n", "Welcome Chantae M. Ross please make a selection",
    									"(1) Check Balance			(5) Cancel",
    									"(2) Withdraw Checking",
    									"(3) Withdraw Savings",
    									"(4) Deposit Funds");
    									
    				selection = option.nextInt();
    				
    					if (selection == 1)	{
    						System.out.printf("%s\n%s\n%s\n\n", "Ross, Sean		acc# 175392", "Available Balance: " + amounts[0],
    														"Available Savings: " + savamounts[0]);
    						
    					} else if (selection == 2) {
    						int selchk;
    						
    						
    						System.out.printf("%s\n", "Please Enter Amount.");
    						selchk = option.nextInt();
    						
    						amounts[0] = amounts[0] - selchk;
    						
    						System.out.printf("%s\n", "Please take your funds your new Balance is: " + amounts[0]);
    					} else if (selection == 3) {
    						int selsav;
    						
    						System.out.printf("%s\n", "Please Enter Amount.");
    						selsav = option.nextInt();
    						
    						savamounts[0] = savamounts - selsav;
    						
    						System.out.printf("%s\n", "Please take your funds your new Balance is: " + savamounts[0]);
    					} else if (selection == 4) {
    						
    						int deposit;
    						
    						System.out.printf("%s\n%s\n\n", "You can only deposit funds into a checking account at this time",
    												  "Please specify the amount to deposit");
    									deposit = option.nextInt();
    									
    									amounts[0] = amounts[0] + deposit;
    									
    						System.out.printf("%s\n\n", "Your new balance is: " + amounts[0]);
    					}	// end of if else		  
    					
    		}	// sean method			
    	
    
    }	// Whole program

    Also here is the error I get when compiling.


    Java Code:
    sean@Port-nix-system:~/programming/java_source$ javac ATM.java
    ATM.java:67: cannot find symbol
    symbol  : method nic()
    location: class ATM
    			nic();	}	else if (Account_Number == "173944" && Pin == 4392)	{
    			^
    ATM.java:68: cannot find symbol
    symbol  : method jo()
    location: class ATM
    			jo();	}	else if (Account_Number == "174796" && Pin == 6869)	{
    			^
    ATM.java:69: cannot find symbol
    symbol  : method bean()
    location: class ATM
    			bean();	}	else if (Account_Number == "148953" && Pin == 3245)	{
    			^
    ATM.java:70: cannot find symbol
    symbol  : method bj()
    location: class ATM
    			bj();	}	else if (Account_Number == "195348" && Pin == 4238)	{
    			^
    ATM.java:71: cannot find symbol
    symbol  : method sarah()
    location: class ATM
    			sarah();	}	else if (Account_Number == "165332" && Pin == 9768)	{
    			^
    ATM.java:72: cannot find symbol
    symbol  : method reg()
    location: class ATM
    			reg();	}	else if (Account_Number == "134987" && Pin == 5459)	{
    			^
    ATM.java:73: cannot find symbol
    symbol  : method tra()
    location: class ATM
    			tra();	}	else if (Account_Number == "192462" && Pin == 6668)	{
    			^
    ATM.java:74: cannot find symbol
    symbol  : method mon()
    location: class ATM
    			mon();	}	else if (Account_Number == "133689" && Pin == 4422)	{
    			^
    ATM.java:75: cannot find symbol
    symbol  : method les()
    location: class ATM
    			les();	}	else { 
    			^
    ATM.java:78: exit(int) in java.lang.System cannot be applied to ()
    				System.exit();
    				      ^
    ATM.java:95: cannot find symbol
    symbol  : variable amounts
    location: class ATM
    						System.out.printf("%s\n%s\n%s\n\n", "Ross, Sean		acc# 175392", "Available Balance: " + amounts[0],
    						                                               		                                      ^
    ATM.java:96: cannot find symbol
    symbol  : variable savamounts
    location: class ATM
    										"Available Savings: " + savamounts[0]);
    										                        ^
    ATM.java:105: cannot find symbol
    symbol  : variable amounts
    location: class ATM
    						amounts[0] = amounts[0] - selchk;
    						^
    ATM.java:105: cannot find symbol
    symbol  : variable amounts
    location: class ATM
    						amounts[0] = amounts[0] - selchk;
    						             ^
    ATM.java:107: cannot find symbol
    symbol  : variable amounts
    location: class ATM
    						System.out.printf("%s\n", "Please take your funds your new Balance is: " + amounts[0]);
    						                                                                           ^
    ATM.java:114: cannot find symbol
    symbol  : variable savamounts
    location: class ATM
    						savamounts[0] = savamounts - selsav;
    						^
    ATM.java:114: cannot find symbol
    symbol  : variable savamounts
    location: class ATM
    						savamounts[0] = savamounts - selsav;
    						                ^
    ATM.java:116: cannot find symbol
    symbol  : variable savamounts
    location: class ATM
    						System.out.printf("%s\n", "Please take your funds your new Balance is: " + savamounts[0]);
    						                                                                           ^
    ATM.java:125: cannot find symbol
    symbol  : variable amounts
    location: class ATM
    									amounts[0] = amounts[0] + deposit;
    									^
    ATM.java:125: cannot find symbol
    symbol  : variable amounts
    location: class ATM
    									amounts[0] = amounts[0] + deposit;
    									             ^
    ATM.java:125: operator + cannot be applied to <any>,int
    									amounts[0] = amounts[0] + deposit;
    									                    ^
    ATM.java:127: cannot find symbol
    symbol  : variable amounts
    location: class ATM
    						System.out.printf("%s\n\n", "Your new balance is: " + amounts[0]);
    						                                                      ^
    22 errors

  2. #2
    Join Date
    Nov 2010
    Posts
    1
    Rep Power
    0

    Default

    You have declared the arrays in main() method but you are trying to access them in sean() method. Take the declaration of arrays outside the methods. Also remember to make them static so they can be used by static methods.

  3. #3
    Join Date
    Jul 2010
    Location
    India
    Posts
    58
    Rep Power
    0

    Default

    I guess you have all these methods ....
    nic(); jo();bean();bj(); sarah();reg();tra();mon();les();
    dont u???

    well if its just that your arrays are not being taken then please define your array inside class not inside main method ... ie define it above your

    public static void main(String[] args)

    as shown
    Java Code:
     private static int[] amounts;
      private static int[] savamounts;
    
        public static void main(String[] args)	{

    Please read about java first ... understand how the basic things work else you will keep bumping into such problems ...

    By the way the whole program is awkward .Do read about string comparision also ..

    warm regards
    Vinod M
    _______________________________________________
    give me beans .........

  4. #4
    seanfmglobal is offline Member
    Join Date
    Nov 2010
    Posts
    40
    Rep Power
    0

    Default

    I understand it is probably somewhat awkward. What I am doing is reading and doing. "Learning" if I just read and read I wont retain anything. It's probably awkward because there are probably much easier ways to put together a simple program like this. But honestly I'm just learning the syntax and how everything flows I guess. Sorry for the horrible coding but I'm sure with much more practice, further reading, and advice my skill will begin to transform into something useful.

  5. #5
    Join Date
    Jul 2010
    Location
    India
    Posts
    58
    Rep Power
    0

    Default

    I understand it is probably somewhat awkward. What I am doing is reading and doing. "Learning" if I just read and read I wont retain anything. It's probably awkward because there are probably much easier ways to put together a simple program like this. But honestly I'm just learning the syntax and how everything flows I guess. Sorry for the horrible coding but I'm sure with much more practice, further reading, and advice my skill will begin to transform into something useful.
    Great... carry on with your learning and we do believe that your skills will become much more than something useful ......


    Happy Coding ...
    _______________________________________________
    give me beans .........

  6. #6
    seanfmglobal is offline Member
    Join Date
    Nov 2010
    Posts
    40
    Rep Power
    0

    Default

    I finished it, it makes since to me now. Now I will be learning the "while" "do". Here is how I finished. Thank you very much for your help.

    Java Code:
    import java.lang.String;
    import java.util.Scanner;
    public class ATM	{
        
        private static int[] amounts;
        private static int[] savamounts;
    	public static void main(String[] args)	{
    	Scanner input = new Scanner(System.in);
    	
    		System.out.printf("%s\n%s\n%s\n%s\n%s\n\n\n",
    		"*  *  *****  *      *      *****",
    		"*  *  *      *      *      *   *",
    		"****  *****  *      *      *   *",
    		"*  *  *      *      *      *   *",
    		"*  *  *****  *****  *****  *****");
    		System.out.printf("%s\n%s\n%s\n%s\n%s\n\n\n",
    		"*     *  *****  *      *****  *****  *******  *****        *****  *****",
    		"*     *  *      *      *      *   *  *  *  *  *              *    *   *",
    		"*     *  *****  *      *      *   *  *     *  *****          *    *   *",
    		"*  *  *  *      *      *      *   *  *     *  *              *    *   *",
    		"*******  *****  *****  *****  *****  *     *  *****          *    *****");
    		System.out.printf("%s\n%s\n%s\n%s\n%s\n\n\n",
    		"*****  ****    ***   *   *  *   *",
    		"  *    *   *  *   *  **  *  *  *",
    		"  *    ****   *****  * * *  ***",
    		"  *    *   *  *   *  *  **  *  *",
    		"*****  ****   *   *  *   *  *   *");
    		
    			
    		
    		amounts = new int[10];      //declares 10 spots for integers
    		
    		amounts[0] = 1793;
    		amounts[1] = 738;
    		amounts[2] = 403;
    		amounts[3] = 9834;
    		amounts[4] = 340;
    		amounts[5] = 4600;
    		amounts[6] = 760;
    		amounts[7] = 640;
    		amounts[8] = 9040;
    		amounts[9] = 1030;
    		
    		
    		savamounts = new int[10];	//declare's 10 for int
    		
    		savamounts[0] = 534;
    		savamounts[1] = 346;
    		savamounts[2] = 6744;
    		savamounts[3] = 3456;
    		savamounts[4] = 376;
    		savamounts[5] = 453;
    		savamounts[6] = 932;
    		savamounts[7] = 349;
    		savamounts[8] = 903;
    		savamounts[9] = 394;
    		
    		
    		String Account_Number; //Var that holds the account number
    		int Pin; //Var that holds pin number to spec account
    		
    		System.out.println("Account Number: ");
    		Account_Number = input.next();
    		
    		System.out.println("Pin: ");
    		Pin = input.nextInt();
    		int counter = 0;
    		if (Account_Number.equals("175392") && Pin == 9090)	{
    			sean();	}	else if (Account_Number.equals("153926")  && Pin == 8887)	{
    			nic();	}	else if (Account_Number.equals("173944") && Pin == 4392)	{
    			jo();	}	else if (Account_Number.equals("174796") && Pin == 6869)	{
    			bean();	}	else if (Account_Number.equals("148953") && Pin == 3245)	{
    			bj();	}	else if (Account_Number.equals("195348") && Pin == 4238)	{
    			sarah();	}	else if (Account_Number.equals("165332") && Pin == 9768)	{
    			reg();	}	else if (Account_Number.equals("134987") && Pin == 5459)	{
    			tra();	}	else if (Account_Number.equals("192462") && Pin == 6668)	{
    			mon();	}	else if (Account_Number.equals("133689") && Pin == 4422)	{
    			les();	}	else { 
    				System.out.println("Information is Invalid... ");
    				
    			}
    	}
    			
    			public static void sean()	{
    				Scanner option = new Scanner(System.in);
    				int selection;
    				
    				System.out.printf("%s\n%s\n%s\n%s\n%s\n\n", "Welcome Chantae M. Ross please make a selection",
    									"(1) Check Balance			(5) Cancel",
    									"(2) Withdraw Checking",
    									"(3) Withdraw Savings",
    									"(4) Deposit Funds");
    									
    				selection = option.nextInt();
    				
    					if (selection == 1)	{
    						System.out.printf("%s\n%s\n%s\n\n", "Ross, Sean		acc# 175392", "Available Balance: " + amounts[0],
    														"Available Savings: " + savamounts[0]);
    						
    					} else if (selection == 2) {
    						int selchk;
    						
    						
    						System.out.printf("%s\n", "Please Enter Amount.");
    						selchk = option.nextInt();
    						
    						amounts[0] = amounts[0] - selchk;
    						
    						System.out.printf("%s\n", "Please take your funds your new Balance is: " + amounts[0]);
    					} else if (selection == 3) {
    						int selsav;
    						
    						System.out.printf("%s\n", "Please Enter Amount.");
    						selsav = option.nextInt();
    						
    						savamounts[0] = savamounts[0] - selsav;
    						
    						System.out.printf("%s\n", "Please take your funds your new Balance is: " + savamounts[0]);
    					} else if (selection == 4) {
    						
    						int deposit;
    						
    						System.out.printf("%s\n%s\n\n", "You can only deposit funds into a checking account at this time",
    												  "Please specify the amount to deposit");
    									deposit = option.nextInt();
    									
    									amounts[0] = amounts[0] + deposit;
    									
    						System.out.printf("%s\n\n", "Your new balance is: " + amounts[0]);
    					}	// end of if else		  
    					
    		}	// end sean method
    
                            public static void nic()    {
                                Scanner option = new Scanner(System.in);
    				int selection;
    
    				System.out.printf("%s\n%s\n%s\n%s\n%s\n\n", "Welcome Nicole R. Ross please make a selection",
    									"(1) Check Balance			(5) Cancel",
    									"(2) Withdraw Checking",
    									"(3) Withdraw Savings",
    									"(4) Deposit Funds");
    
    				selection = option.nextInt();
    
    					if (selection == 1)	{
    						System.out.printf("%s\n%s\n%s\n\n", "Ross, Nicole		acc# 153926", "Available Balance: " + amounts[1],
    														"Available Savings: " + savamounts[1]);
    
    					} else if (selection == 2) {
    						int selchk;
    
    
    						System.out.printf("%s\n", "Please Enter Amount.");
    						selchk = option.nextInt();
    
    						amounts[1] = amounts[1] - selchk;
    
    						System.out.printf("%s\n", "Please take your funds your new Balance is: " + amounts[1]);
    					} else if (selection == 3) {
    						int selsav;
    
    						System.out.printf("%s\n", "Please Enter Amount.");
    						selsav = option.nextInt();
    
    						savamounts[1] = savamounts[1] - selsav;
    
    						System.out.printf("%s\n", "Please take your funds your new Balance is: " + savamounts[1]);
    					} else if (selection == 4) {
    
    						int deposit;
    
    						System.out.printf("%s\n%s\n\n", "You can only deposit funds into a checking account at this time",
    												  "Please specify the amount to deposit");
    									deposit = option.nextInt();
    
    									amounts[1] = amounts[1] + deposit;
    
    						System.out.printf("%s\n\n", "Your new balance is: " + amounts[1]);
    					}	// end of if else
    
    
                            }           // end nic method
    
                            public static void jo()     {
    
                                Scanner option = new Scanner(System.in);
    				int selection;
    
    				System.out.printf("%s\n%s\n%s\n%s\n%s\n\n", "Welcome Josiah R. Reaux please make a selection",
    									"(1) Check Balance			(5) Cancel",
    									"(2) Withdraw Checking",
    									"(3) Withdraw Savings",
    									"(4) Deposit Funds");
    
    				selection = option.nextInt();
    
    					if (selection == 1)	{
    						System.out.printf("%s\n%s\n%s\n\n", "Reaux, Josiah		acc# 173944", "Available Balance: " + amounts[2],
    														"Available Savings: " + savamounts[2]);
    
    					} else if (selection == 2) {
    						int selchk;
    
    
    						System.out.printf("%s\n", "Please Enter Amount.");
    						selchk = option.nextInt();
    
    						amounts[2] = amounts[2] - selchk;
    
    						System.out.printf("%s\n", "Please take your funds your new Balance is: " + amounts[2]);
    					} else if (selection == 3) {
    						int selsav;
    
    						System.out.printf("%s\n", "Please Enter Amount.");
    						selsav = option.nextInt();
    
    						savamounts[2] = savamounts[2] - selsav;
    
    						System.out.printf("%s\n", "Please take your funds your new Balance is: " + savamounts[2]);
    					} else if (selection == 4) {
    
    						int deposit;
    
    						System.out.printf("%s\n%s\n\n", "You can only deposit funds into a checking account at this time",
    												  "Please specify the amount to deposit");
    									deposit = option.nextInt();
    
    									amounts[2] = amounts[2] + deposit;
    
    						System.out.printf("%s\n\n", "Your new balance is: " + amounts[2]);
    					}	// end of if else
    
    
    
                            }       // end jo method
    
                            public static void bean()   {
                                Scanner option = new Scanner(System.in);
    				int selection;
    
    				System.out.printf("%s\n%s\n%s\n%s\n%s\n\n", "Welcome Alisiah L. Velasquez please make a selection",
    									"(1) Check Balance			(5) Cancel",
    									"(2) Withdraw Checking",
    									"(3) Withdraw Savings",
    									"(4) Deposit Funds");
    
    				selection = option.nextInt();
    
    					if (selection == 1)	{
    						System.out.printf("%s\n%s\n%s\n\n", "Velasquez, Alisiah		acc# 174796", "Available Balance: " + amounts[3],
    														"Available Savings: " + savamounts[3]);
    
    					} else if (selection == 2) {
    						int selchk;
    
    
    						System.out.printf("%s\n", "Please Enter Amount.");
    						selchk = option.nextInt();
    
    						amounts[3] = amounts[3] - selchk;
    
    						System.out.printf("%s\n", "Please take your funds your new Balance is: " + amounts[3]);
    					} else if (selection == 3) {
    						int selsav;
    
    						System.out.printf("%s\n", "Please Enter Amount.");
    						selsav = option.nextInt();
    
    						savamounts[3] = savamounts[3] - selsav;
    
    						System.out.printf("%s\n", "Please take your funds your new Balance is: " + savamounts[3]);
    					} else if (selection == 4) {
    
    						int deposit;
    
    						System.out.printf("%s\n%s\n\n", "You can only deposit funds into a checking account at this time",
    												  "Please specify the amount to deposit");
    									deposit = option.nextInt();
    
    									amounts[3] = amounts[3] + deposit;
    
    						System.out.printf("%s\n\n", "Your new balance is: " + amounts[3]);
    					}	// end of if else
    
    
    
    
                            }   // end bean method
    
                            public static void bj()     {
    
    
                                Scanner option = new Scanner(System.in);
    				int selection;
    
    				System.out.printf("%s\n%s\n%s\n%s\n%s\n\n", "Welcome Brian M. Jackson please make a selection",
    									"(1) Check Balance			(5) Cancel",
    									"(2) Withdraw Checking",
    									"(3) Withdraw Savings",
    									"(4) Deposit Funds");
    
    				selection = option.nextInt();
    
    					if (selection == 1)	{
    						System.out.printf("%s\n%s\n%s\n\n", "Jackson, Brian		acc# 148953", "Available Balance: " + amounts[4],
    														"Available Savings: " + savamounts[4]);
    
    					} else if (selection == 2) {
    						int selchk;
    
    
    						System.out.printf("%s\n", "Please Enter Amount.");
    						selchk = option.nextInt();
    
    						amounts[4] = amounts[4] - selchk;
    
    						System.out.printf("%s\n", "Please take your funds your new Balance is: " + amounts[4]);
    					} else if (selection == 3) {
    						int selsav;
    
    						System.out.printf("%s\n", "Please Enter Amount.");
    						selsav = option.nextInt();
    
    						savamounts[4] = savamounts[4] - selsav;
    
    						System.out.printf("%s\n", "Please take your funds your new Balance is: " + savamounts[4]);
    					} else if (selection == 4) {
    
    						int deposit;
    
    						System.out.printf("%s\n%s\n\n", "You can only deposit funds into a checking account at this time",
    												  "Please specify the amount to deposit");
    									deposit = option.nextInt();
    
    									amounts[4] = amounts[4] + deposit;
    
    						System.out.printf("%s\n\n", "Your new balance is: " + amounts[4]);
    					}	// end of if else
    
                            }   // end bj method
    
                            public static void sarah()  {
    
                                Scanner option = new Scanner(System.in);
    				int selection;
    
    				System.out.printf("%s\n%s\n%s\n%s\n%s\n\n", "Welcome Sarah Valero please make a selection",
    									"(1) Check Balance			(5) Cancel",
    									"(2) Withdraw Checking",
    									"(3) Withdraw Savings",
    									"(4) Deposit Funds");
    
    				selection = option.nextInt();
    
    					if (selection == 1)	{
    						System.out.printf("%s\n%s\n%s\n\n", "Valero, Sarah		acc# 195348", "Available Balance: " + amounts[5],
    														"Available Savings: " + savamounts[5]);
    
    					} else if (selection == 2) {
    						int selchk;
    
    
    						System.out.printf("%s\n", "Please Enter Amount.");
    						selchk = option.nextInt();
    
    						amounts[5] = amounts[5] - selchk;
    
    						System.out.printf("%s\n", "Please take your funds your new Balance is: " + amounts[5]);
    					} else if (selection == 3) {
    						int selsav;
    
    						System.out.printf("%s\n", "Please Enter Amount.");
    						selsav = option.nextInt();
    
    						savamounts[5] = savamounts[5] - selsav;
    
    						System.out.printf("%s\n", "Please take your funds your new Balance is: " + savamounts[5]);
    					} else if (selection == 4) {
    
    						int deposit;
    
    						System.out.printf("%s\n%s\n\n", "You can only deposit funds into a checking account at this time",
    												  "Please specify the amount to deposit");
    									deposit = option.nextInt();
    
    									amounts[5] = amounts[5] + deposit;
    
    						System.out.printf("%s\n\n", "Your new balance is: " + amounts[5]);
    					}	// end of if else
    
    
                            }   // end sarah method
    
                            public static void reg()    {
    
                                Scanner option = new Scanner(System.in);
    				int selection;
    
    				System.out.printf("%s\n%s\n%s\n%s\n%s\n\n", "Welcome Reginald Ross please make a selection",
    									"(1) Check Balance			(5) Cancel",
    									"(2) Withdraw Checking",
    									"(3) Withdraw Savings",
    									"(4) Deposit Funds");
    
    				selection = option.nextInt();
    
    					if (selection == 1)	{
    						System.out.printf("%s\n%s\n%s\n\n", "Ross, Reginald		acc# 165332", "Available Balance: " + amounts[6],
    														"Available Savings: " + savamounts[6]);
    
    					} else if (selection == 2) {
    						int selchk;
    
    
    						System.out.printf("%s\n", "Please Enter Amount.");
    						selchk = option.nextInt();
    
    						amounts[6] = amounts[6] - selchk;
    
    						System.out.printf("%s\n", "Please take your funds your new Balance is: " + amounts[6]);
    					} else if (selection == 3) {
    						int selsav;
    
    						System.out.printf("%s\n", "Please Enter Amount.");
    						selsav = option.nextInt();
    
    						savamounts[6] = savamounts[6] - selsav;
    
    						System.out.printf("%s\n", "Please take your funds your new Balance is: " + savamounts[6]);
    					} else if (selection == 4) {
    
    						int deposit;
    
    						System.out.printf("%s\n%s\n\n", "You can only deposit funds into a checking account at this time",
    												  "Please specify the amount to deposit");
    									deposit = option.nextInt();
    
    									amounts[6] = amounts[6] + deposit;
    
    						System.out.printf("%s\n\n", "Your new balance is: " + amounts[6]);
    					}	// end of if else
    
    
    
                            }   // end reg method
    
                            public static void tra()    {
    
                                Scanner option = new Scanner(System.in);
    				int selection;
    
    				System.out.printf("%s\n%s\n%s\n%s\n%s\n\n", "Welcome Tracy Gastellum please make a selection",
    									"(1) Check Balance			(5) Cancel",
    									"(2) Withdraw Checking",
    									"(3) Withdraw Savings",
    									"(4) Deposit Funds");
    
    				selection = option.nextInt();
    
    					if (selection == 1)	{
    						System.out.printf("%s\n%s\n%s\n\n", "Gastellum, Tracy		acc# 134987", "Available Balance: " + amounts[7],
    														"Available Savings: " + savamounts[7]);
    
    					} else if (selection == 2) {
    						int selchk;
    
    
    						System.out.printf("%s\n", "Please Enter Amount.");
    						selchk = option.nextInt();
    
    						amounts[7] = amounts[7] - selchk;
    
    						System.out.printf("%s\n", "Please take your funds your new Balance is: " + amounts[7]);
    					} else if (selection == 3) {
    						int selsav;
    
    						System.out.printf("%s\n", "Please Enter Amount.");
    						selsav = option.nextInt();
    
    						savamounts[7] = savamounts[7] - selsav;
    
    						System.out.printf("%s\n", "Please take your funds your new Balance is: " + savamounts[7]);
    					} else if (selection == 4) {
    
    						int deposit;
    
    						System.out.printf("%s\n%s\n\n", "You can only deposit funds into a checking account at this time",
    												  "Please specify the amount to deposit");
    									deposit = option.nextInt();
    
    									amounts[7] = amounts[7] + deposit;
    
    						System.out.printf("%s\n\n", "Your new balance is: " + amounts[7]);
    					}	// end of if else
    
    
                            }   // end tracy method
    
                            public static void mon()    {
    
                                Scanner option = new Scanner(System.in);
    				int selection;
    
    				System.out.printf("%s\n%s\n%s\n%s\n%s\n\n", "Welcome Monica Montes please make a selection",
    									"(1) Check Balance			(5) Cancel",
    									"(2) Withdraw Checking",
    									"(3) Withdraw Savings",
    									"(4) Deposit Funds");
    
    				selection = option.nextInt();
    
    					if (selection == 1)	{
    						System.out.printf("%s\n%s\n%s\n\n", "Montes, Monica		acc# 192462", "Available Balance: " + amounts[8],
    														"Available Savings: " + savamounts[8]);
    
    					} else if (selection == 2) {
    						int selchk;
    
    
    						System.out.printf("%s\n", "Please Enter Amount.");
    						selchk = option.nextInt();
    
    						amounts[8] = amounts[8] - selchk;
    
    						System.out.printf("%s\n", "Please take your funds your new Balance is: " + amounts[8]);
    					} else if (selection == 3) {
    						int selsav;
    
    						System.out.printf("%s\n", "Please Enter Amount.");
    						selsav = option.nextInt();
    
    						savamounts[8] = savamounts[8] - selsav;
    
    						System.out.printf("%s\n", "Please take your funds your new Balance is: " + savamounts[8]);
    					} else if (selection == 4) {
    
    						int deposit;
    
    						System.out.printf("%s\n%s\n\n", "You can only deposit funds into a checking account at this time",
    												  "Please specify the amount to deposit");
    									deposit = option.nextInt();
    
    									amounts[8] = amounts[8] + deposit;
    
    						System.out.printf("%s\n\n", "Your new balance is: " + amounts[8]);
    					}	// end of if else
    
    
                            }   // end monica method
    
                            public static void les()    {
    
    
                                Scanner option = new Scanner(System.in);
    				int selection;
    
    				System.out.printf("%s\n%s\n%s\n%s\n%s\n\n", "Welcome Leslie Blake please make a selection",
    									"(1) Check Balance			(5) Cancel",
    									"(2) Withdraw Checking",
    									"(3) Withdraw Savings",
    									"(4) Deposit Funds");
    
    				selection = option.nextInt();
    
    					if (selection == 1)	{
    						System.out.printf("%s\n%s\n%s\n\n", "Blake, Leslie		acc# 133689", "Available Balance: " + amounts[9],
    														"Available Savings: " + savamounts[9]);
    
    					} else if (selection == 2) {
    						int selchk;
    
    
    						System.out.printf("%s\n", "Please Enter Amount.");
    						selchk = option.nextInt();
    
    						amounts[9] = amounts[9] - selchk;
    
    						System.out.printf("%s\n", "Please take your funds your new Balance is: " + amounts[9]);
    					} else if (selection == 3) {
    						int selsav;
    
    						System.out.printf("%s\n", "Please Enter Amount.");
    						selsav = option.nextInt();
    
    						savamounts[9] = savamounts[9] - selsav;
    
    						System.out.printf("%s\n", "Please take your funds your new Balance is: " + savamounts[9]);
    					} else if (selection == 4) {
    
    						int deposit;
    
    						System.out.printf("%s\n%s\n\n", "You can only deposit funds into a checking account at this time",
    												  "Please specify the amount to deposit");
    									deposit = option.nextInt();
    
    									amounts[9] = amounts[9] + deposit;
    
    						System.out.printf("%s\n\n", "Your new balance is: " + amounts[9]);
    					}	// end of if else
    
    
                            }   // end leslie method
    
    
    
    
    
    
    
    }	// Whole program

    Thank you guys so much

  7. #7
    off99555 is offline Member
    Join Date
    Dec 2010
    Posts
    11
    Rep Power
    0

    Default

    Your code is too long... But it is not the problem you can fix it, the problem is that you will leave away of Java programming.

    I have some suggestions for you.
    1. Use operator +=,0 -=, *=, %=, /= rather than amounts[0] = amounts[0] + 10
    You just use amounts[0] += 10
    2. Your method is the same code, its performance is not good.

    Training your programming skill will keep you has some new knowledge, and your code will have more compact.

  8. #8
    seanfmglobal is offline Member
    Join Date
    Nov 2010
    Posts
    40
    Rep Power
    0

    Default

    so can I place a variable there for ex.

    Java Code:
    amounts[2] += deposits;
    ??

  9. #9
    off99555 is offline Member
    Join Date
    Dec 2010
    Posts
    11
    Rep Power
    0

    Default

    Quote Originally Posted by seanfmglobal View Post
    so can I place a variable there for ex.

    Java Code:
    amounts[2] += deposits;
    ??
    Yes, it is!

    And oh, I have looked your code again and i found a complex code
    amounts = new int[10]; //declares 10 spots for integers

    amounts[0] = 1793;
    amounts[1] = 738;
    amounts[2] = 403;
    amounts[3] = 9834;
    amounts[4] = 340;
    amounts[5] = 4600;
    amounts[6] = 760;
    amounts[7] = 640;
    amounts[8] = 9040;
    amounts[9] = 1030;
    You can replace them with the following code:
    amounts = {1793,738,403,9834,340,4600,760,640,9040,1030};
    Is it easier for you? But for me, it is. You do not need to declare its size like new int[10].

    and on your method, it doesn't has any parameter like les(int i, int b), so you need to copy it and rename. It is has a lot of method that has the same code. It is hard to read.
    public static void les() {


    Scanner option = new Scanner(System.in);
    int selection;

    System.out.printf("%s\n%s\n%s\n%s\n%s\n\n", "Welcome Leslie Blake please make a selection",
    "(1) Check Balance (5) Cancel",
    "(2) Withdraw Checking",
    "(3) Withdraw Savings",
    "(4) Deposit Funds");

    selection = option.nextInt();

    if (selection == 1) {
    System.out.printf("%s\n%s\n%s\n\n", "Blake, Leslie acc# 133689", "Available Balance: " + amounts[9],
    "Available Savings: " + savamounts[9]);

    } else if (selection == 2) {
    int selchk;


    System.out.printf("%s\n", "Please Enter Amount.");
    selchk = option.nextInt();

    amounts[9] = amounts[9] - selchk;

    System.out.printf("%s\n", "Please take your funds your new Balance is: " + amounts[9]);
    } else if (selection == 3) {
    int selsav;

    System.out.printf("%s\n", "Please Enter Amount.");
    selsav = option.nextInt();

    savamounts[9] = savamounts[9] - selsav;

    System.out.printf("%s\n", "Please take your funds your new Balance is: " + savamounts[9]);
    } else if (selection == 4) {

    int deposit;

    System.out.printf("%s\n%s\n\n", "You can only deposit funds into a checking account at this time",
    "Please specify the amount to deposit");
    deposit = option.nextInt();

    amounts[9] = amounts[9] + deposit;

    System.out.printf("%s\n\n", "Your new balance is: " + amounts[9]);
    } // end of if else


    } // end leslie method
    I have made it a new look, and you just tried all(amounts[0], savamounts[0]), all(amounts[1], savamounts[1]). It is very more compact! You don't need to copy and rename it as a new method. One method calling is enough.
    public static void all(int amount, int savamount) {


    Scanner option = new Scanner(System.in);
    int selection;

    System.out.printf("%s\n%s\n%s\n%s\n%s\n\n", "Welcome Leslie Blake please make a selection",
    "(1) Check Balance (5) Cancel",
    "(2) Withdraw Checking",
    "(3) Withdraw Savings",
    "(4) Deposit Funds");

    selection = option.nextInt();

    if (selection == 1) {
    System.out.printf("%s\n%s\n%s\n\n", "Blake, Leslie acc# 133689", "Available Balance: " + amount,
    "Available Savings: " + savamount);

    } else if (selection == 2) {
    int selchk;


    System.out.printf("%s\n", "Please Enter Amount.");
    selchk = option.nextInt();

    //amounts[9] = amounts[9] - selchk;
    amount -= selchk;

    System.out.printf("%s\n", "Please take your funds your new Balance is: " + amounts[9]);
    } else if (selection == 3) {
    int selsav;

    System.out.printf("%s\n", "Please Enter Amount.");
    selsav = option.nextInt();

    //savamounts[9] = savamounts[9] - selsav;

    savamount -= selsav;
    System.out.printf("%s\n", "Please take your funds your new Balance is: " + savamount);
    } else if (selection == 4) {

    int deposit;

    System.out.printf("%s\n%s\n\n", "You can only deposit funds into a checking account at this time",
    "Please specify the amount to deposit");
    deposit = option.nextInt();

    //amounts[9] = amounts[9] + deposit;
    amount += deposit;

    System.out.printf("%s\n\n", "Your new balance is: " + amount);
    } // end of if else


    } // end all method
    And another one lesson, Java doesn't have only System.out.printf(); It also has System.out.println() which print a line without '\n' expression;

    If you found that you need to copy some code to some where like amounts word that has a lot, it means that your code is not compact yet, but you are the beginner. I have been before. The beginner can't receive many knowledge at the short time, I think because I have many experience with it like I like Maths, Computer, English so I have learned it easy but the social, I hate it because I have so little knowledge about it, when I tried to learn it, it is very hard and I can't remember it. So don't think that Java is hard, this feeling will only happens with you on the starting time.

    If you don't understand me, I think it is correct because I'm just began practice writing English like you that practice writing Java! It took a lot of time since I started writing this post until now about 30 minutes even my typing skill is excellent because I must choose a word from my brain that I have learned from my teacher. Hahaha! I must practice more...
    Last edited by off99555; 12-25-2010 at 07:22 PM.
    I'm a teenage Thai Java programmer who studying in secondary school.
    Practicing English in process ...

Similar Threads

  1. class not found
    By meong in forum JDBC
    Replies: 7
    Last Post: 09-22-2010, 12:25 PM
  2. file not found
    By smartshahezad in forum JDBC
    Replies: 2
    Last Post: 03-04-2010, 12:14 PM
  3. Jsp source not found
    By jadeite100 in forum Web Frameworks
    Replies: 2
    Last Post: 01-19-2010, 03:23 PM
  4. No JVM found error
    By rocky05 in forum New To Java
    Replies: 1
    Last Post: 01-27-2009, 04:41 PM
  5. 404 Not Found
    By mary in forum Java Servlet
    Replies: 5
    Last Post: 11-07-2007, 11:15 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •