Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old May 11th, 2006, 7:21 AM   #11
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
I have no problem with your asking for clarification, that's often needed. Your following post, well.... If pointing out the need for clarity, as well as suggesting some places to peer into, was enough to 'scare him away', it doesn't bode well for his teachability. Just sayin', as the OP hasn't suggested that at all.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old May 11th, 2006, 8:13 AM   #12
ReggaetonKing
Sexy Programmer
 
ReggaetonKing's Avatar
 
Join Date: Nov 2005
Location: New Jersey
Posts: 891
Rep Power: 4 ReggaetonKing is on a distinguished road
Send a message via AIM to ReggaetonKing
Not enough members read the forum faqs and rules. It's their own fault, if they don't receive a reply when asking for help but instead being corrected. One expects help and doesn't do their part , this irritates me as well as you.
__________________
I would love to change the world, but they won't give me the source code!
ReggaetonKing is offline   Reply With Quote
Old May 11th, 2006, 5:31 PM   #13
NightShade01
Programmer
 
Join Date: Oct 2005
Posts: 52
Rep Power: 4 NightShade01 is on a distinguished road
Your're both right in the fact that not enough people read the posting rules not only in this forum but for any forum for that matter. And you didnt' scare me away I just realized after reading all your comments and replies that I clearly didn't know enough about arrays or for loops to pose a question in the correct fashion so i spent the rest of last night reading and trying to learn something about the two topics. And sry again for not being clear....i need to make a program that outputs:
1 A B C D
2 A B C D
3 A B C D
4 A B C D
5 A B C D
6 A B C D
7 A B C D
then after outputing this it should prompt the user for a choice of where they want to sit.(the assortment of letters and numbers are suppose to represent an airplane seating chart).
NightShade01 is offline   Reply With Quote
Old May 11th, 2006, 6:04 PM   #14
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Precisely how one would do it would depend on the language. This is the Java forum, and I really don't plan on going back to Java, but consider this approach:

Use a two-dimensional array for a seating plan, just as you've shown it. Initialize all the elements to blank. Output it, formatted, much as you have shown it. Move into your input loop. Accept as input a row/seat pair, and maybe a name. Map that row/seat pair to a row/column position in the array. Place something in that element; passenger name, big X, "occupado", whatever flips your skirt. Output it, formatted as before. My engineers actually produced something like this as part of a larger program back in about 1991.

'For' loops are simple. If you want an explanation, post back. It'll no doubt be virtually identical to what your learning materials say.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old May 11th, 2006, 6:14 PM   #15
NightShade01
Programmer
 
Join Date: Oct 2005
Posts: 52
Rep Power: 4 NightShade01 is on a distinguished road
Thanks for the advice it helped alot! I read back over what i had orignally and fixed up my for loops and array. Now i have this:
 int[][] seat;
    seat = new int[7][5];
    
    int row, column;
    for(row = 0; row < 7; row++){
      
      for(column = 0; column < 5; column++){
        seat[0][0] = 1;
        seat[1][0] = 2;
        seat[2][0] = 3;
        seat[3][0] = 4;
        seat[4][0] = 5;
        seat[5][0] = 6;
        seat[6][0] = 7;
        System.out.print(seat[row][column]+ " ");
      }
        System.out.println();
    }
My question is more of, once this is compile it output's:
1 0 0 0 0
2 0 0 0 0
3 0 0 0 0
4 0 0 0 0
5 0 0 0 0
6 0 0 0 0
7 0 0 0 0
how would i replace the "0's" with letters if the array is of type int?
NightShade01 is offline   Reply With Quote
Old May 11th, 2006, 6:22 PM   #16
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Don't make it of type int. One can put text representations of numbers in a text container, but not vice versa. After all, your screen isn't showing an int, it's showing a presentational encoding of an int.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old May 11th, 2006, 10:53 PM   #17
lectricpharaoh
SEXY SHOELESS GOD OF WAR!
 
lectricpharaoh's Avatar
 
Join Date: Jun 2005
Location: Wet west coast of Canada
Posts: 1,193
Rep Power: 5 lectricpharaoh will become famous soon enough
Quote:
Originally Posted by NightShade01
My question is more of, once this is compile it output's:
1 0 0 0 0
2 0 0 0 0
3 0 0 0 0
4 0 0 0 0
5 0 0 0 0
6 0 0 0 0
7 0 0 0 0
how would i replace the "0's" with letters if the array is of type int?
How do you want to store the data? If you want a simple 'vacant/occupied' flag, then use boolean, and then you can perform a check on the seat's status, and output the appropriate text. If you want the passenger's ticket ID, use a numeric type (assuming the ticket ID is not alphanumeric). If you want an alphanumeric piece of text (name, ticket ID with letters, dashes, etc), then use String.

In any case, you should be able to check the status, with a predefined value indicating vacancy. For data types of boolean, int, and String, you could use false, 0, and "" (empty text), respectively.
__________________
And once again, Probability proves itself willing to sneak into a back alley and service Drama as would a copper-piece harlot.
- Vaarsuvius, Order of the Stick
lectricpharaoh is offline   Reply With Quote
Old May 11th, 2006, 11:21 PM   #18
titaniumdecoy
Expert Programmer
 
titaniumdecoy's Avatar
 
Join Date: Nov 2005
Posts: 931
Rep Power: 4 titaniumdecoy is on a distinguished road
Send a message via AIM to titaniumdecoy
In your original post, you were displaying the seating chart as the letters A-D. I would use an array of chars, and print the row number (int row) before each line.
titaniumdecoy is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 3:14 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC