• Post Reply Bookmark Topic Watch Topic
  • New Topic

Assignment

 
Amna Arif
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey !
can anybody help me. My teacher assigned me a program in java using i/o streams, filing. i don't know how to program in filing perfectly. So if anybody can provide me the solution, i will be really grateful. Here's the objective.
Make a program for a small airline. the program will assign seats to flight of airline's only plane having 100 seats. your program must display following menu of alternatives "Please Type 1 for First Class" and "Please Type 2 for Economy Class". If a person press 1, your program should assign a seat in the First Class section (seats 1-50). If a person press 2, your program should assign a seat in the Economy Class section (seats 51-100). your program should print a boarding pass indicationg the person's seat in number and whether it is First class or economy section.
your program shoild never assign a seat twice. if first class or economy sections are filled then your program should diplay the message. "Wait for reservation of the next flight".
 
jason adam
Chicken Farmer ()
Ranch Hand
Posts: 1932
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy Amna, a couple of things about posting assignments.
First, most people aren't going to give you the answer. The whole purpose of an assignment is to learn. You don't learn anything if you're handed the solution on a silver platter.
Second, most people shy away from helping you if you don't at least try. Perhaps if you posted some code that you've attempted to get working, we can help point you in the right direction.
 
Amna Arif
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually my exams are near and i know nothing about this program how to do it. so if you guide me how to start and what methods, constructors, I/O streams must be used. please help
 
jason adam
Chicken Farmer ()
Ranch Hand
Posts: 1932
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, at a really simple level, here's how I would approach it.
- Have 2 flat files that have two columns. One is the seat number, the other is "Available" or "Unavailable". One file is for First Class, one for Coach.
- When the person requests first class or coach, use a BufferedReader to read in the appropriate file. Use a StringTokenizer to break apart the String read from each line, and create a Map that has mappings between seat number to availability (Integer object to String object mapping).
- Work with the maps until the person confirms their seat. Once that is done, use a PrintWriter to write out each mapping to a line.
The I/O API gives the descriptions of these classes. The only methods you need for input/output are BufferedReader.readLine() and PrintWriter.println( String ).
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!