[VIEWED 4091
TIMES]
|
SAVE! for ease of future access.
|
|
|
score
Please log in to subscribe to score's postings.
Posted on 07-16-08 11:22
PM
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
plz guyz urgent help,
i have been asked to write an application to assign seats in airlines reservation system with capacity 10. should display: please type 1 for First Class and please type 2 for Economy. type 1 is from seat 0-5 and type 2 from 6-10, then it should display boarding pass indicatin person's seat no. and Economy or First class.
USE ONE DIMENSION ARRAY OF PRIMITIVE TYPE BOOLEAN TO REPRESENT THE SEATING CHART OF THE PLNAE. INITIALIZE ALL THE ELEMENTS OF THE ARRAY TO false TO INDICATE ALL SEATS ARE EMPTY AND ASSIGN true TO INDICATE SEATS NO FURTHER AVAILLABE. AS WEL SHOULD ASK IF ECONOMY CLASS IS FULL, IF A PERSON WANTS A SEAT FROM FIRST CLASS AND VICE-VERSA. IF NO SEATS, DISPLAY THE MESAGE"NEXT FLIGHT LEAVE IN 3 HOURS"
i m in great need of the program to be done.
anyone with the idea plz........i m so poor in Java.......this that i do't know anything i just started online...........course....its getting my nerve. thankx in advance
|
|
|
|
Brain Malfunction
Please log in to subscribe to Brain Malfunction's postings.
Posted on 07-17-08 12:13
AM
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
Score,
Following is C++ code, you can certainly see what is going on because JAVA is similar syntax. Plus both languages speak English too.
Or ask for some JAVA GURU of SAJHA for translation..
hope it helps you!
#include <iostream> using namespace std;
#include <cctype> using std::toupper;
int main() { const int SEATS = 11; int flight[ SEATS ] = { 0 }; int passenger = 0; int coach = 6; int firstClass = 1; int choice; char response;
while ( passenger < 10 ) { cout << "\nPress 1 for \"The Creamy Front Seats\"\n" << "Press 2 for \"Old and Dirty Back Seats\"\n"; cin >> choice;
if ( choice == 1 ) { if ( !flight[ firstClass ] && firstClass <= 5 ) //first class available seating { cout << "Your seat is " << firstClass << " in the Super Sweet Front Section.\n"; flight[ firstClass++ ] = 1; passenger++; } // end if else if ( firstClass > 5 && coach <= 10 ) // take economy seating { cout << "The Ultra Kewl People section is full.\nWould you " << "like to sit With the Animals (Y or N)? "; cin >> response; if ( toupper( response ) == 'Y' ) { cout << "Your seat is " << coach << " in the Back Half of The Plane.\n"; flight[ coach++ ] = 1; passenger++; } // end if else cout << "Next flight in 3 hours so you'd better hurry up.\n"; } // end outer else else cout << "Next flight in 3 hours this means you.\n"; } // end outer if else { if ( !flight[ coach ] && coach <= 10 ) // seat available { cout << "Your seat is " << coach << " in the crappy part of town.\n"; flight[ coach++ ] = 1; passenger++; } // end if else if ( firstClass <= 5 ) { cout << "The poor people section is full.\nWould you like " << "to sit in the upperclass section (Y or N)? "; cin >> response;
if ( toupper( response ) == 'Y' ) { cout << "Your seat is " << firstClass << " in the rich part of town.\n"; flight[ firstClass++ ] = 1; passenger++; } // end if else cout << "Next flight in 3 hours you'd better hurry up.\n"; } // end outer else else cout << "Next flight in 3 hours put a rush on that.\n"; } // end outer if } // end while
cout << "All of the seats are gone, sorry but you suck." << endl; return 0; }
|
|
|
the_hareeb
Please log in to subscribe to the_hareeb's postings.
Posted on 07-17-08 10:37
AM
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
how is c# compare to java/c++ ?
|
|
|
the_hareeb
Please log in to subscribe to the_hareeb's postings.
Posted on 07-17-08 10:40
AM
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
brain malfunction, i like your comments :D. I dont think customers would want to book tickets from your code.
|
|
|
score
Please log in to subscribe to score's postings.
Posted on 07-18-08 7:32
AM
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
anyone plz
can you translate this in to JAVA code
i told you dude i m poor in Java but i m doing my best
thankx for help
|
|
|
SAJHACOP
Please log in to subscribe to SAJHACOP's postings.
Posted on 07-18-08 1:08
PM
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
Score, if you can not translate above code in Java, you are wasting your time on Java for sure. I don't even know Java and here is my take. package ticket; import java.io.IOException; import java.util.Scanner; import java.util.Arrays; public class BP2 { public static void main(String[] args) throws IOException { final int SEATS = 11; int passenger = 0; int coach = 6; int firstClass = 1; int choice; char response; boolean[] flight = new boolean[SEATS]; Arrays.fill(flight, false); Scanner sc = new Scanner(System.in); while (passenger < 10) { System.out.println("Press 1 for \"The Creamy Front Seats\"\n" + "Press 2 for \"Old and Dirty Back Seats\"\n"); choice = sc.nextInt(); if (choice == 1) { if(!flight[firstClass] && firstClass <= 5) { System.out.println("Your seat is " + firstClass + " in the Super Sweet Front Section."); flight[firstClass++] = true; passenger++; } else if (firstClass > 5 && coach <= 10) { System.out.println("The Ultra Kewl People section is full.\n"+ "Would you like to sit With the Animals (Y or N)?"); response = (char)System.in.read(); if (response == 'Y' || response == 'y') { System.out.println("Your seat is " + coach + " in the Back Half of The Plane.\n"); flight[coach++] = true; passenger++; } else { System.out.println("Next Flight in 3 hours so you'd better hurry up."); } } else System.out.println("Next flight in 3 hours this means you."); } else { if(!flight[coach] && coach <= 10) { System.out.println("Your seat is " + coach + " in the crappy part of town."); flight[coach++] = true; passenger++; } else if (firstClass <= 5) { System.out.println("The poor people section is full.\n" + "Would you like to sit in the upperclass section ( Y or N)?"); response = (char)System.in.read(); if (response == 'Y' || response == 'y') { System.out.println("Your seat is " + firstClass + " in the rich part of town.\n"); passenger++; } else { System.out.println("Next flight in 3 hours you'd better hurry up."); } } else { System.out.println("Next flight in 3 hours put a rush on that."); } } } System.out.println("All of the seats are gone, sorry but you suck."); }
}
I might be wrong though, but it compiles.
Last edited: 18-Jul-08 01:13 PM
|
|
|
score
Please log in to subscribe to score's postings.
Posted on 07-19-08 12:42
AM
Reply
[Subscribe]
|
Login in to Rate this Post:
0
?
|
|
thankx
i havenot done even C++ as well
|
|