# Thread: Train simulation

1. ## Train simulation

I was given an assignment but I don't know much about c programming. please i will like to know more that's the reason I have decided to join this forum.

A new metro system is to be constructed by an independent company somewhere in the UK to link up 10 stations in a line (not a loop). The name of the station s are as follows:-
Ashford - Brentworth - Canonbury Cross - Dowgate - Edbury - Fenchurch Street - Gresham - Hampstead - Islington - Jamaica Road

The distance between each of the stations is fairly equal therefore the ticket cost between each station is £2.00 with an extra 50% added on for a return journey.

Example: A return ticket from brentworth to hampstead will cost £18.00

The company would like a user friendly piece of software to operate their ticket machines. All that is required at this stage is that the software does the following:-
1. The user can select a departure station
2. The user can select an arrival station
3. the user can select either single or return journey.

The program must then display on the screen a suitable summary of the ticket that the user can check prior to accepting and and paying.

please can anyone help me out with this? I will really appreciate your feedback or comment(s)

2. Welcome to the forum, mikel360

You need to put together a start for your program, and then we can assist in some concrete way.

You'll need a menu. Something like this function, but with different options and such, of course.

Same basic logic. Main() calls menu(), menu calls everything else (or close to it).

Code:
```int menu (void)
{
double avg_score; .
int choice, scores[SIZE], hi_score, lo_score;
get_score(scores);

do {
printf("\nMenu option one    1");
printf("\nMenu option two    2");
printf("\nMenu option three  3");
printf("\nQUIT enter         4");
printf("\nEnter your choice: ");
scanf("%d", &choice);
(void) getchar(); //clean the input of newline char

switch (choice) {
case 1: //your code might call many other functions here
break;
case 2: //to handle all these possible choices
break;
case 3: //your code here
break;
case 4: //your code here
break;
default:
printf("Error! Try again please\n");
}
}while(choice != 4);

return 0; //or (0)
}```

3. No code, no feedback.

4. Decide how the user will enter in the station names. Likely not typing them in but rather by a menu choice, numeric... Then devise a calculation based on departure & arrival station number plus calculation for return trip.

5. thank you guys for your feedback. I will post my code soon

Popular pages Recent additions