Closed Thread
Results 1 to 2 of 2

Thread: College assignment

  1. #1
    Raebus is offline Newbie
    Join Date
    Jan 2009
    Posts
    1
    Rep Power
    0

    College assignment

    Code:
    program bus;
    
    uses
    	wincrt;
    
    Var
       parray:array [1..9] of real;
       countperson,thedate,startingpoint,endpoint,selection, tickettotal:integer;
       Number,cashgiven,recieved:real;
       quit:boolean;
       Returntrip:char;
       Tickettype:string;
    
    Procedure pause;
    begin
      Writeln;
      Writeln;
      Writeln('Please press enter to continue');
      Readln;
    
    End;
    
    	Procedure child;
    			begin
                            Number:= 0;
    			clrscr;
    
      		        parray[1] := 0.70;
      		        parray[2] := 0.80;
       			parray[3] := 0.75;
       			parray[4] := 1.10;
       			parray[5] := 0.75;
       			parray[6] := 1.40;
       			parray[7] := 1.55;
       			parray[8] := 0.50;
       			parray[9] := 0.00;
    
        		        Writeln('Please enter your start point ');
       			readln(startingpoint);
       			Writeln('Please enter your stopping point ');
      			readln(endpoint);
                            Writeln;
                            Writeln('Would you like a return: y/n');
                            readln(Returntrip);
                            Writeln('Cash given:');
                            readln(cashgiven);
    
                            If (Returntrip = 'y') or (Returntrip = 'Y') then
             	           Begin
                                 For tickettotal := startingpoint to (endpoint-1) DO
       			         begin
            		              Number := Number + parray[tickettotal]*1.50;
                                          recieved := cashgiven - Number;
                                          countperson := countperson + 1;
                                     end;
    
                                 End
       			else
                            Begin
                   	             For tickettotal :=Startingpoint to (endpoint-1) DO
       							begin
            		        		             Number := Number + parray[tickettotal];
                                                                 recieved := cashgiven - Number;
       			                                     countperson := countperson + 1;
                                                             end
                           	End;
      			      	Writeln('The total trip will cost ',Number:6:2);
                   	                Writeln('Your change is ',recieved:6:2);
                                    Writeln('Number of passengers ',countperson);
    
    
    pause;
    End;
    
    Procedure adult;
    begin
    
                                    Number:= 0;
                                    clrscr;
    		                parray[1] := 1.00;
    		                parray[2] := 1.20;
    				parray[3] := 1.05;
                                    parray[4] := 1.56;
    				parray[5] := 1.05;
    				parray[6] := 1.90;
    				parray[7] := 2.10;
    				parray[8] := 0.80;
    				parray[9] := 0.00;
    
    				Writeln('Please enter your start point ');
       				readln(startingpoint);
       				Writeln('Please enter your stopping point ');
      				readln(endpoint);
                                    Writeln;
                                    Writeln('Would you like a return: y/n');
                                    readln(Returntrip);
                                    Writeln('Cash given:');
                                    readln(cashgiven);
    
                                    If (Returntrip = 'y') or (Returntrip = 'Y') then
                	                    Begin
                    	               For tickettotal :=Startingpoint to (endpoint-1) DO
       		                         begin
            			          Number := Number + parray[tickettotal]*1.60;
                                              recieved := cashgiven - Number;
                                              countperson := countperson + 1;
                                             end;
                                         End
                     else
    
    		    	         Begin
                                 For tickettotal :=Startingpoint to (endpoint-1) DO
       					       begin
            		  	                Number := Number + parray[tickettotal];
                                                    recieved := cashgiven - Number;
                                                    countperson := countperson + 1;
                                                   end
                            End;
                            Writeln('The total trip will cost ',Number:6:2);
                            Writeln('Your change is ',recieved:6:2);
                            Writeln('Number of passengers ',countperson);
    pause;
    End;
    
    
    Procedure OAP;
    begin
    			Number:= 0;
    			clrscr;
    			parray[1] := 0.75;
    			parray[2] := 0.85;
    			parray[3] := 0.80;
    			parray[4] := 1.20;
    			parray[5] := 0.80;
    			parray[6] := 1.55;
    			parray[7] := 1.75;
    			parray[8] := 0.65;
    			parray[9] := 0.00;
    
    			Writeln('Please enter your start point ');
    			readln(startingpoint);
    			Writeln('Please enter your stopping point ');
    			readln(endpoint);
                            Writeln('Would you like a return ticket: y/n');
                            readln(Returntrip);
                            Writeln('Cash given:');
                            readln(cashgiven);
    
                            If (Returntrip = 'y') or (Returntrip = 'Y') then
                                           Begin
                                                For tickettotal :=Startingpoint to (endpoint-1) DO
       			                        begin
            			                 Number := Number + parray[tickettotal]*1.55;
                                                     recieved := cashgiven - Number;
       			                         end;
                                           End
                      else
                           	        Begin
                    	             For tickettotal :=Startingpoint to (endpoint-1) DO
       			                 begin
            			            Number := Number + parray[tickettotal];
                                                recieved := cashgiven - Number;
                                          end
                            End;
       			            Writeln('The total trip will cost ',Number:6:2);
                                        Writeln('Your change is ',recieved:6:2);
    
    pause;
    End;
    
    Procedure Ticket;
                    begin
                    clrscr;
                    Writeln('===============================================================');
                    Writeln('===============================================================');
                    {Writeln('Travel this way busses				Date 	');}
                    Writeln;
                    Writeln('=                                                              ');
                    Writeln('Ticket number: ',countperson,'    Boarded stop: ',startingpoint);
                    Writeln;
                    Writeln('=				    Alighted stop     : ',endpoint);
                    Writeln;
                    {Writeln('=				    Type             : ',ticketype);}
                    Writeln;
                    Writeln('=				    Price	      : ',Number);
                    end;
    
    
    
    
    Procedure menu;
    				begin
                	clrscr;
                	quit :=false;
                	repeat;
                	Writeln('------------------------------------------');
                	Writeln('------------------------------------------');
                   	Writeln('1.adult');
                    Writeln;
                    Writeln('2.child');
                    Writeln;
                    Writeln('3.OAP');
                    Writeln;
                    Writeln('4.quit');
                    Writeln;
                    Writeln('5.Ticket');
                    Writeln('-------------------------------------------');
                    Writeln('-------------------------------------------');
    
                    writeln;
                    writeln('Please make your selection ');
                	readln(selection);
    
                   		case selection of
                    		1: adult;
                    		2: child;
                    		3: OAP;
                    		4: quit :=true;
                                    5: Ticket;
                  			end;
                  			clrscr;
                   		        until quit;
                		        end;
    
    
    {main program}
    
    begin
    	menu;
    
    end.
    I have to create a program that would take bus tickets and I've done alright up to this point but my main problem now is the ticket procedure. I want it to show the results of a ticket i.e for a childs ticket or adults ticket. Does anyone have any suggestions?
    Last edited by WingedPanther; 01-30-2009 at 10:44 AM. Reason: add code tags (the # button)

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    Join Date
    Jul 2006
    Posts
    16,491
    Blog Entries
    75
    Rep Power
    143

    Re: College assignment

    You can handle the output within the adult/child function, or you can change the procedure to a function that hands output back to the ticket function.
    Programming is a branch of mathematics.
    My CodeCall Blog | My Personal Blog

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. SSH at College
    By Calgon in forum Linux/Unix General
    Replies: 7
    Last Post: 11-06-2010, 09:40 AM
  2. What is your college?
    By isuru in forum The Lounge
    Replies: 18
    Last Post: 08-04-2010, 12:12 PM
  3. Help needed for college assignment (with arrays)
    By juniordee in forum Visual Basic Programming
    Replies: 3
    Last Post: 02-08-2010, 03:02 AM
  4. Tricky college assignment
    By sandbagger in forum C and C++
    Replies: 1
    Last Post: 12-06-2009, 01:14 AM
  5. You Know You're Out Of College When...
    By mnhaqeel in forum The Lounge
    Replies: 0
    Last Post: 01-16-2007, 11:46 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts