473,465 Members | 2,103 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

need help with if statement actions

2 New Member
hello,

im working on a program that simulates a library, in this library there are 4 classes: llibrary, book, patron, and libraryMain.

In libraryMain, i'm using if statements to allow the user to input text into the menu, choosing different options. When i run the program, it runs through the if statements in order, so i cant enter something like "show patrons" without it executing the "invalid entry" string from the previous case.

i would like the to allow input for every set of cases at the same time without going in order.

Expand|Select|Wrap|Line Numbers
  1. String input;
  2.  
  3.         System.out.print("Enter a selection: ");
  4.  
  5.         input = in.nextLine();
  6.  
  7.         // add/remove books control
  8.         if (input.equalsIgnoreCase("add a book"))
  9.         {
  10.             System.out.println("Enter book to add: ");    
  11.         }        
  12.         else if (input.equalsIgnoreCase("remove book"))
  13.         {    
  14.             System.out.println("Enter book to remove: ");
  15.         }
  16.         else
  17.         {
  18.             System.out.println("Invalid Entry");
  19.         }
  20.  
  21.         System.out.print("Enter a selection: "); 
May 1 '10 #1
2 1129
Dheeraj Joshi
1,123 Recognized Expert Top Contributor
I can not see any patron object created in the code. Is it the complete code?

Regards
Dheeraj Joshi
May 1 '10 #2
KRXB
2 New Member
oh, my apologies. i attached all 4 classes, i don't have a lot done on them yet, but thats why im looking for guidance.

thanks Dheeraj Joshi
Attached Files
File Type: txt Library.txt (436 Bytes, 364 views)
File Type: txt LibraryMain.txt (1.7 KB, 365 views)
File Type: txt Book.txt (394 Bytes, 370 views)
File Type: txt Patron.txt (198 Bytes, 359 views)
May 1 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: ABC | last post by:
Which statement on the C# has live-as VB's "With" Statement?
4
by: doodle | last post by:
access 97 can someone tell me the syntax for a with stement for multiple controls? pseudo (doesn't work) With cmbBox1,cmbBox2,cmbBox3 .Visible = False End With
3
by: Ashok Guduru | last post by:
Hi, I'm new to C#. In VB.NET we have With...End With Statement. Often, I need to perform several different actions on the same object. For example, I may need to set several properties or...
1
by: Gunawan | last post by:
Hi All, When using vb I could use with statement to make access to property/method shorter Dim cmd AS new SqlCommand with cmd.parameters .AddWithValue() .... end with
33
by: =?Utf-8?B?RE9UTkVUR1VZ?= | last post by:
Hello, In vb.net there is a with statement, Is there are similar constructor in c#?
11
by: Nhan | last post by:
Hi, is there equivalent statement in C# as WITH ... END in VB? instead of: frm.dataGridView1.AutoGenerateColumns = true; frm.dataGridView1.DataSource = l_oDataset;...
2
by: Dmitry Teslenko | last post by:
Hello! I've made some class that can be used with "with statement". It looks this way: class chdir_to_file( object ): .... def __enter__(self): .... def __exit__(self, type, val, tb): ....
2
by: mk | last post by:
Hello, I'm trying to learn how with statement can be used to avoid writing: prepare() try: something_that_can_raise_SomeException() except SomeException, err: deal_with_SomeException...
4
by: braver | last post by:
Can open two files in a with statement: with open(src) as readin, open(dst,"w") as writin: # WRONG: comma doesn't work ... -- so that you have transactional safety for two file descriptors?...
5
by: peppergrower | last post by:
I've been experimenting with the 'with' statement (in __future__), and so far I like it. However, I can't get it to work with a cStringIO object. Here's a minimum working example: ### from...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.