Re: Java Gurus Help
- From: "Andrew.Bell" <zen62619@xxxxxxxxx>
- Date: Sun, 12 Mar 2006 00:11:42 -0000
IchBin your good, I understand what you mean. Went to compile the code and
got this error.
C:\Java\MiniBank2.java:4: cannot find symbol
symbol : class Scanner
location: class MiniBank2
static Scanner easyIn = new Scanner(System.in);
^
C:\Java\MiniBank2.java:4: cannot find symbol
symbol : class Scanner
location: class MiniBank2
static Scanner easyIn = new Scanner(System.in);
^
2 errors
Tool completed with exit code 1
Do you no what this means ?
"IchBin" <weconsul@xxxxxxx> wrote in message
news:zNednaNIBeLb_47ZUSdV9g@xxxxxxxxxx
Andrew.Bell wrote:
This is what I have so far.
//Andrew Bell
Andrew, I tighten up some of the code. It works for your first option now.
You can see how I did because you will have to add new methods for your
other new options. I use a two dim array to hold your data for customer
and options. This cuts down on a lot of extra code. You may want to change
it to an arraylist object so that you will be able to add new accounts or
options dynamically and not worry about the size of the array.
You did not pass along that *EasyIn* object so I just used the Scanner
class. This is close to what you were using. You can change it back but
you will have to change a few Strings to chars. You should do that.
Also, your code was very confusing because it did not follow any naming
convention. At least Java guidelines for naming your vars. You had all
upper case on the first letter of your var objects. Class names are the
only objects that have a uppercase first char of objects name. You will
see when you look at the code. You did a good job as far as I can tell.
You can see the Java coding conventions at this page:
http://java.sun.com/docs/codeconv/html/CodeConvTOC.doc.html
You can look at my website under my personal tab I have a section on Java.
It is not as nice as most but then I just keep it for myself and if
anybody can use it, fine. For me, its beats keeping a ton of URL's in
Bookmarks across multiple browsers.
If you have any questions just let me know.. or someone else can help
also..
For coding examples, say for an arraylist, you can goto Sun's Java
Developers Almanac, http://javaalmanac.com and search for arraylist or any
things you are trying to do.
[snip old code]
import java.util.Scanner;
public class MiniBank
{
static Scanner easyIn = new Scanner(System.in);
static String validTransactionOptions = "ABCDEFXabcdefx";
static boolean done = false;
//
// Instead using a 2 dim array to hold value Accounttype by customer
static int[][] customerArray = new int[5][4];
static String title[] = {"Current Account ", "ISA ",
"Mortgage ", "Car Loan "};
static String ConfigMenu[] = {
"A. For a specific customer, display details of their
accounts.",
"B. Get the ballance in an account for a specified customer.",
"C. Add to an account for a specific customer.",
"D. Withdraw from an account for a specified customer.",
"E. Get the total funds in all of the current accounts in the
bank.",
"F. Get the total funds in all of the ISA's in the bank.",
"X. Finished."};
static char choice;
static int customer;
public static void main(String args[])
{
System.out.println(" ");
System.out.println("Welcome To The Mini Bank");
System.out.println("------------------------");
System.out.println(" ");
for (int nCustomer = 1; nCustomer < 5; nCustomer++) // outer loop
for customers
{
for (int ntransaction = 0; ntransaction < 4; ntransaction++)//
inner loop for amounts
{
System.out.print("Please Enter Amount For Customer "
+ nCustomer + "'s "
+ title[ ntransaction]
+ "= ");
// Using just one Two dim array
customerArray[nCustomer][ntransaction] = easyIn.nextInt();
}
}
//
//User Menu
System.out.println(" ");
System.out.println("Configuration Menu");
System.out.println("--------------------");
for (int i=0; i<6; i++)
{
System.out.println(ConfigMenu[i]);
}
System.out.println(" ");
System.out.println(" ");
//
// Loop and process untill done
while (!done) {
getTransactionOption();
}
}
public static void getTransactionOption()
{
System.out.print("Please select an option from the above menu
(A,B,C,D,E For X) = ");
String schoice = easyIn.next() ;
//
// Check for valid
if (validTransactionOptions.indexOf(schoice) > -1)
{
if(schoice.equals("X") || schoice.equals("x"))
done = true;
else
{
System.out.print("Please select a customer. (1,2,3 or 4) = ");
getDisplayInformation(schoice, easyIn.nextInt());
}
}
else
{
System.out.println("Error: Invalid option selected");
System.exit(9);
}
}
static void getDisplayInformation(String schoice, int customer)
{
int typeTransaction = 0;
if(schoice.equals("A") || schoice.equals("a"))
typeTransaction = 0;
else if(schoice.equals("B") || schoice.equals("b"))
typeTransaction = 1;
else if(schoice.equals("C") || schoice.equals("c"))
typeTransaction = 2;
else if(schoice.equals("D") || schoice.equals("d"))
typeTransaction = 3;
else if(schoice.equals("E") || schoice.equals("e"))
typeTransaction = 4;
else if(schoice.equals("F") || schoice.equals("f"))
typeTransaction = 5;
else
{
System.out.println("Error: Bad Transaction Type");
return;
}
System.out.println();
System.out.println("Customer "+customer+" Information for Selected
Option '"
+ schoice + "' is: "+
customerArray[customer][typeTransaction]);
System.out.println();
}
}
Thanks in Advance...
IchBin, Pocono Lake, Pa, USA
http://weconsultants.servebeer.com/JHackerAppManager
__________________________________________________________________________
'If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
.
- Follow-Ups:
- Re: Java Gurus Help
- From: IchBin
- Re: Java Gurus Help
- References:
- Java Gurus Help
- From: Andrew Bell
- Re: Java Gurus Help
- From: IchBin
- Re: Java Gurus Help
- From: Andrew.Bell
- Re: Java Gurus Help
- From: IchBin
- Java Gurus Help
- Prev by Date: Re: Java Gurus Help
- Next by Date: Re: Java Gurus Help
- Previous by thread: Re: Java Gurus Help
- Next by thread: Re: Java Gurus Help
- Index(es):
Relevant Pages
|
|