• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

airline ticket generator

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys I'm new to java and have been doing some exercises.one in particular is where I have to prompt the user to enter their details,such as name, surname and ID number.i then have to generate a random number for each persons info I put in.the part I'm lost at is where I have to create a multidimensional array to store the information generated from the ticket and then ask the user if they want to view the passenger list and then print the passenger list with the user's information.now I know there will be a multidimensional array and for loops but I'm not exactly sure how to do this
 
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch!

First, that exercise sounds like a good example of how NOT to do things in Java.

Next, is this homework or self-study? If it's homework, then don't you have any notes from class? What part of your textbook are you on? That should have information about how to use loops with nested arrays.

Next, Java doesn't have true multidimensional arrays. You can simulate them using nested arrays. That is, arrays whose elements are themselves arrays. Nesting of arrays can be multiple levels deep.

If you are doing self study, then refer to the Official Java Tutorials.
 
tevin billings
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is self study,I've been searching the internet for help based on what I'm doing.i tried loading the code I've done so far but doesn't seem to want to upload.i have a brief understanding of what an array is,declaring it ,etc.where I'm stuck is how to take the information generated from the ticket and creating an array to take that info and displaying it on a list for the user to see
 
Saloon Keeper
Posts: 15510
363
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Forget arrays for now. Arrays are for multiple instances of the same type of thing. You want to gather related but different types of things about a person together, so you should be creating a class for that.

Create a Person class, and show to us that you can create an instance of it and fill it with data that a user entered. Don't worry about a complete passenger list yet.
 
tevin billings
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How do I add the code to coderanch?
 
Junilu Lacar
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please don't post all your code; only post the parts you think has problems. UseCodeTags (← click) when posting code.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic