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

Alphabet Pyramid

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
I am writing a program (no gui) for assigning customers to airline seating. I have included the requirements from my instructor. Looking for advice about how I have approached things. I am currently getting a compile error that sticks on the 'catch' statement. I can't figure it out. Any comments, advice, or code examples would be greatly appreciated. Thank You ahead of time, this forum has been a great help to my Java beginnings, although I am still a newbie, I will one day help others here, as others have helped me....
Code:
--------------------------------------------------------------------------------

/*POS 407February 15Week Four DQ Part IIRequirements:A small airline has just purchased a computer for its new automated reservations system. The president has asked you to program the new system in Java. You are to write a program to assign seats on each flight of the airline�s only plane (capacity: 10 seats). Your program should display the following menu of alternatives lease type 1 for �smoking�Please type 2 for �nonsmoking�If the person types 1, then your program should assign a seat in the smoking section (seats 1-5). If the person types 2, then your program should assign a seat in the nonsmoking section (seats 6-10). Your program should then print a boarding pass indication the person�s seat number and whether it is in smokingor nonsmoking section of the plane. Use a single subscript array to represent the seating char of the plane. Initialize all the elements of the array to 0 to indicate all seats are empty. As each seat is assigned, set the corresponding elements of the array to 1 to indicate that the seat is no longer available.Your program should, of course, never assign a seat that has already been assigned. When the smoking section is full, your program should ask the person if it is acceptable to be placed in the nonsmoking section (and vice versa). If yes, then make the appropriate seat assignment. If no, then print the message �Next flight leaves in 3 hours�*/ import java.io.*; import java.util.*; import java.lang.*; public class boardingPass{ public static void main(String[] arguments) { String[] booking = new String[9]; int userInput; int yesNo; int i = 0; System.out.println("Please type 1 for 'smoking' section or 2 for 'non-smoking' section. Press 'enter' when done."); try{//try open userInput = System.in.read();//a bit of error checking, but I need a little more... while( i <= 10){//for open if(userInput == 1){//if open for(int s = 0; s <= 5; s++){//for open System.out.println("Boarding Pass: Smoking Seat:" + booking[s]); System.out.println("Would you like to book another seat? [y/n]. Press 'enter' when done."); yesNo = System.in.read(); if(yesNo == 'y') return; else System.exit(0); i++; }//for close }//if close else{//else open for(int n = 5; n <= 10; n++){//for open System.out.println("Boarding Pass: Non-Smoking Seat:" + booking[n]); System.out.println("Would you like to book another sear? [y/n]. Press 'enter' when done."); yesNo = System.in.read(); if(yesNo == 'y') return; else System.exit(0); i++; }//for close }//else close System.out.println("Next flight leaves in 3 hours"); }//for close }catch(Exception e){ System.out.println("error"); } finally{ System.out.println("Thank You");} } }
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
"david dee oh double gee",
while we're an extremely friendly and helpfull bunch here at the 'Ranch, we do have our limits.

Firstly your display name is invalid. Please edit your profile and fix your display name it that it has your first name, a space, then your last name. Invalid account get deleted.

Secondly, you'll need to format that mess before anyone will even attempt to look at it. Using the UBB 'code' tags will also help (you'll see them at the bottom of the page when you edit your post)

Lastly, this looks like homework. You'll find we're quite happy to give pointers and lead you to a solution, but at no stage will a solution be provided. If someone does post a solution, usually a moderator will delete it.

Best of luck and welcome to the JavaRanch!

Dave
 
David J. Gonzo
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Yes I made the changes to my profile. I am new to this forum and was unaware how it would post my 'paste'. It won't happen again...

It is an assignment, but I have all of the code compiling but just have a problem with the right half of the pyramid.



apologies,
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Continue discussion here.
    Bookmark Topic Watch Topic
  • New Topic