Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / April 2008

Tip: Looking for answers? Try searching our database.

Automated teller machine help please

Thread view: 
Totti - 25 Apr 2008 11:53 GMT
Hi all,
i m trying to make a program (client/server) of a Automated teller
machine talking with its bank server. i did it using 3 files, a
client,
a server and an application. the program contains 2 bugs that i
woud like you to help me solve them

1- the program take random choice for working or not which is too
weird to me (i m a beginer)
the program may work for one time properly, then not then yes,
eventhough i compile everytime.
eventhough i know that this is not something possible in programming
terms, but indeed it is highly possible to compile, try to run and it
breaks and after 1 minute, compile again and run nicely

2-  whenever i enter a right value, i go to the right step if i enter
the password before the username it will not prompt me about a user
name . Instead, in case the pass i give is the right one, i go to the
next step
which is "main menu", what i want is to go step by step the
procedure,
like if anything except the UserName was given even a right pass. the
program shall not take it, it should remain in the UserName step
untill entered correctly

for this, i suppose the problem is in the IF statements but i m not
sure how to fix them so i will show you what are the 'IF' i m using
on
both sides and if you can, please help!

Fom the client side:
               modifiedsentence = inFromServer.readLine();
               String onoma = "MyBank";
               String onoma1 = "MyName";
               String Pass = "MyPass";

               if (modifiedsentence.equalsIgnoreCase(onoma))
               {
                       System.out.println("Enter your User Name");
               }
               if (modifiedsentence.equalsIgnoreCase(onoma1))
               {
                       System.out.println("Enter your Password");
               }
               if (modifiedsentence.equalsIgnoreCase(Pass))
               {
                       System.out.println(" ");
                       System.out.println("MAIN MENU");
                       System.out.println("---------");
                       System.out.println("* w for Withdrawal");
                       System.out.println("* d for Deposit");
                       System.out.println("* c for check Balance");

// here the program wil run the third file or the application file
}
---------------------------------------------------------------------------­---------------------------------------
From the server side:
               clientsentence = inFromClient.readLine();
               //Ask for a cardNumber
               Accepted = clientsentence.toUpperCase() +"\n";
               NotAccepted = clientsentence.toUpperCase() +" is NOT
accepted "+
"\n";
               String Nom = "MyBank";
               String PreNom = "MyName";
               String PassWord = "MyPass";

               if (clientsentence.equalsIgnoreCase(Nom))
               {
                       outToClient.writeBytes(Accepted);
               }
               if (clientsentence.equalsIgnoreCase(PreNom))
               {
                       outToClient.writeBytes(Accepted);
               }
               if (clientsentence.equalsIgnoreCase(PassWord))
               {
                       outToClient.writeBytes(Accepted);
               }
               else
               {
               outToClient.writeBytes(NotAccepted);
               }
==========================================================
i m pretty sure the problem is here so i must nest 'IF' in some way
or
something else should be done, like making a separate readline for
each new line entered by the ATM user, i really dont know what to do
from here on, would you please help

Thank you all
RedGrittyBrick - 25 Apr 2008 14:40 GMT
> Hi all,

Please read all of
http://www.catb.org/~esr/faqs/smart-questions.html
I think you may find it helpful.

> i m trying to make a program (client/server) of a Automated teller
> machine talking with its bank server. i did it using 3 files,

I think you mean three classes, maybe you mean three programs.

> a client, a server and an application.

A program is an application, I find your description confusing.

> the program contains 2 bugs that i
> woud like you to help me solve them
[quoted text clipped - 6 lines]
> terms, but indeed it is highly possible to compile, try to run and it
> breaks and after 1 minute, compile again and run nicely

It sounds like a timing issue. Maybe you are trying to use some resource
before it is ready, sometimes you are lucky and it is ready in time.
Don't forget your computer is doing other tasks in the background so
these may have small but significant effects on the timing of various
events in your application.

> 2-  whenever i enter a right value, i go to the right step if i enter
> the password before the username it will not prompt me about a user
[quoted text clipped - 5 lines]
> program shall not take it, it should remain in the UserName step
> untill entered correctly

You don't provide enough code for me to see where your problem lies. I
suggest you write a separate small programs whose job is to prompt the
user for those things in the order you want them. If it works, apply
what you learned to your ATM program. If it doesn't work post it here
and say what it actually does and what you expected it to do.

http://sscce.org/

> for this, i suppose the problem is in the IF statements but i m not
> sure how to fix them so i will show you what are the 'IF' i m using
[quoted text clipped - 6 lines]
>                 String onoma1 = "MyName";
>                 String Pass = "MyPass";

Your variable names are uninformative, this makes the program harder to
read.

>                 if (modifiedsentence.equalsIgnoreCase(onoma))
>                 {
[quoted text clipped - 26 lines]
>                 String PreNom = "MyName";
>                 String PassWord = "MyPass";

These variable names are inconsistent with those used in the client.
A well-established Java convention is that variable names start with
lower case letters. Your variable names look like class names. This
makes your code harder to read and understand.

>                 if (clientsentence.equalsIgnoreCase(Nom))
>                 {
[quoted text clipped - 14 lines]
> ==========================================================
> i m pretty sure the problem is here

I'm not.

> so i must nest 'IF' in some way
> or
> something else should be done, like making a separate readline for
> each new line entered by the ATM user, i really dont know what to do
> from here on, would you please help

You need to wrap those If statements in some sort of loop that continues
prompting until all inputs are complete.

Nesting the If statements may help. I'd avoid them by having the client
encode the keywords as a data type that can be used in a switch
statement. You haven't described what the client passes to the server
and it's not clear to me from your code.

Signature

RGB



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.