Welcome to Dream.In.Code
Become a Java Expert!

Join 150,042 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 1,593 people online right now. Registration is fast and FREE... Join Now!




correct this program

 
Reply to this topicStart new topic

correct this program

javapro91
4 Jun, 2008 - 01:33 AM
Post #1

New D.I.C Head
*

Joined: 4 Jun, 2008
Posts: 1

java

class Air{
String pa;
Air(String passenger){
pa=passenger;
passenger="\0"
}
public static void main(String args[]){
String passenger;
passenger=args[0];
if(passenger=="Ram"){
system.out.println(" *** ALL INDIA TRANSPORT ***);
system.out.println("\n");
system.out.println(" *** AIR TICKET ***);
system.out.println("Passenger Name : Mr. s.Ram");
system.out.println("Flight Name : Indian Airlines");
system.out.println("Flight Number : 75946E");
system.out.println("Boarding Point : Chennai");
system.out.println("Destination Point: Malaysia");
system.out.println("Departure date
& time : 06/02/2008 1900 hrs");
system.out.println("Arrival Date
& Time : 06/10/2008 2200 hrs");
system.out.println("Ticket Fair : Rs 23000/- ");
}
else if(args[0]=="Jeny"){
system.out.println(" *** ALL INDIA TRANSPORT ***);
system.out.println("\n");
system.out.println(" *** AIR TICKET ***);
system.out.println("\n");
system.out.println("Passenger Name : Miss. G.Jeny");
system.out.println("Flight Name : Singapore Airlines");
system.out.println("Flight Number : 25643F");
system.out.println("Boarding Point : Chennai");
system.out.println("Destination Point: Singapore");
system.out.println("Departure date
& time : 07/01/2008 1500 hrs");
system.out.println("Arrival Date
& Time : 08/18/2008 2000 hrs");
system.out.println("Ticket Fair : Rs 43000/- ");

}
else if(args[0]=="Siva"){
system.out.println(" *** ALL INDIA TRANSPORT ***);
system.out.println("\n");
system.out.println(" *** AIR TICKET ***);
system.out.println("\n");
system.out.println("Passenger Name : Mr. K.Siva");
system.out.println("Flight Name : Indian Airlines");
system.out.println("Flight Number : 75946E");
system.out.println("Boarding Point : Chennai");
system.out.println("Destination Point: Delhi");
system.out.println("Departure date
& time : 06/05/2008 1000 hrs");
system.out.println("Arrival Date
& Time : 06/19/2008 1230 hrs");
system.out.println("Ticket Fair : Rs 13000/- ");
}
else{
system.out.println(" Error: check your detail !!!!!!!! ");
}
}
}

** Edit ** code.gif
User is offlineProfile CardPM
+Quote Post

no2pencil
RE: Correct This Program
4 Jun, 2008 - 01:36 AM
Post #2

My fridge be runnin OH NOEZ!
Group Icon

Joined: 10 May, 2007
Posts: 7,154



Thanked: 78 times
Dream Kudos: 2425
Expert In: Goofing Off

My Contributions
I see a bunch of code... what's the problem?

a.) It doesn't compile
b.) It compiles but has warnings
c.) It compiles but doesn't perform like I want it to
d.) I don't know, I downloaded it not knowing what it does, & my assignment is due soon
User is online!Profile CardPM
+Quote Post

chopChop
RE: Correct This Program
4 Jun, 2008 - 06:21 AM
Post #3

New D.I.C Head
*

Joined: 28 May, 2008
Posts: 7


My Contributions
Very strange lookin bunch of code at that! Some sort of weird data holder - dont understand why or when you would ever want to use a main method like this but then I will admit to being of limited knowledge.

From what I can see, executing this program would do nothing? Cant check if it even compiles coz im at work.

Second guess. Looks like your attempting to invoke the main method with a parameter of passenger name and have main display the details to the console?



User is offlineProfile CardPM
+Quote Post

pbl
RE: Correct This Program
4 Jun, 2008 - 09:24 AM
Post #4

D.I.C Lover
Group Icon

Joined: 6 Mar, 2008
Posts: 3,587



Thanked: 233 times
Dream Kudos: 75
My Contributions
QUOTE(chopChop @ 4 Jun, 2008 - 07:21 AM) *

Looks like your attempting to invoke the main method with a parameter of passenger name and have main display the details to the console


Yes that's all what it does. Prints kind of a ticket depending of the three valid passenger names passed as parameter when invoking the program.

User is online!Profile CardPM
+Quote Post

fsloke
RE: Correct This Program
5 Jun, 2008 - 04:08 AM
Post #5

D.I.C Regular
***

Joined: 19 Dec, 2007
Posts: 258



Thanked: 4 times
My Contributions
javapro91, I don't what you want to do.....

But I already help you to resolve the warning and error...

Here is the code:

CODE

class Air{
    String pa;
    public Air(String passenger){
        pa=passenger;
        passenger= "";
        }
    public static void main(String args[]){
        String passenger;
        passenger=args[0];
    if(passenger.equals("Ram")){
        System.out.println("    *** ALL INDIA TRANSPORT ***");
        System.out.println("\n");
        System.out.println("         *** AIR TICKET ***");
        System.out.println("Passenger Name   : Mr. s.Ram");
        System.out.println("Flight Name      : Indian Airlines");
        System.out.println("Flight Number    : 75946E");
        System.out.println("Boarding Point   : Chennai");
        System.out.println("Destination Point: Malaysia");
        System.out.println("Departure date "
                    + "time       : 06/02/2008 1900 hrs");
        System.out.println("Arrival Date"
                    + "Time       : 06/10/2008 2200 hrs");
        System.out.println("Ticket Fair      : Rs 23000/- ");
        }
    else if(args[0].equals("Jeny")){
        System.out.println("    *** ALL INDIA TRANSPORT ***");
        System.out.println("\n");
        System.out.println("         *** AIR TICKET ***");
        System.out.println("\n");
        System.out.println("Passenger Name   : Miss. G.Jeny");
        System.out.println("Flight Name      : Singapore Airlines");
        System.out.println("Flight Number    : 25643F");
        System.out.println("Boarding Point   : Chennai");
        System.out.println("Destination Point: Singapore");
        System.out.println("Departure date"
                    +" time       : 07/01/2008 1500 hrs");
        System.out.println("Arrival Date"
                    +" Time       : 08/18/2008 2000 hrs");
        System.out.println("Ticket Fair      : Rs 43000/- ");
        
}
    else if(args[0].equals("Siva")){
        System.out.println("    *** ALL INDIA TRANSPORT *** ");
        System.out.println("\n");
        System.out.println("         *** AIR TICKET ***");
        System.out.println("\n");
        System.out.println("Passenger Name   : Mr. K.Siva");
        System.out.println("Flight Name      : Indian Airlines");
        System.out.println("Flight Number    : 75946E");
        System.out.println("Boarding Point   : Chennai");
        System.out.println("Destination Point: Delhi");
        System.out.println("Departure date"
                    +" time       : 06/05/2008 1000 hrs");
        System.out.println("Arrival Date"
                    +" Time       : 06/19/2008 1230 hrs");
        System.out.println("Ticket Fair      : Rs 13000/- ");
}
else{
        System.out.println(" Error: check your detail !!!!!!!! ");
}
}
}

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/8/09 09:54PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Java Help!

Java Tutorials

Reference Sheets

Java Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month