I need help to calculate the ticket price from the number of stops between arrival and departure station
Code:
#include <stdio.h>
int main(void) {
int input, i;
const char *station[] = {
"Ashford Station", "Brentworth Station",
"Canonbury Cross Station", "Dowgate Station",
"Edbury Station", "Fenchurch Street Station",
"Gresham Station", "Hampstead Station",
"Islington Station", "Jamaica Road Station"
};
for (i = 0; i < 10; i++) {
printf("%d. %s\n", i + 1, station[i]);
}
printf("11. Exit\n");
printf("Departure Station:");
scanf("%d", &input);
if ((1 <= input) && (input <= 11)) {
if (input == 11) printf("Thanks\n");
else printf("%s\n", station[input - 1]);
} else {
printf("Invalid input, quitting!\n");
}
printf("Arrival Station:");
scanf("%d", &input);
if ((1 <= input) && (input <= 11)) {
if (input == 11) printf("Thanks\n");
else printf("%s\n", station[input - 1]);
} else {
printf("Invalid input, quitting!\n");
}
{{float ticketcost=2.00f, returncost=0.0f,singlecost=0.0f, priceofjourney =0.0f;
int x,y,s;
i >=0&& i<=10;
i>=0 && i<=10;
s = i + i;
singlecost=ticketcost*s;
returncost=singlecost * (singlecost/2);
} }
{float ticketcost=2.00f, returncost=0.0f, s =0.0f, singlecost=0.0f, priceofjourney =0.0f;
{int choice;
printf("\nEnter Either 1 for Single Journey or 2 for Return Journey:");
scanf("%d", &choice);
if (choice==1)
{
printf("\nPrice of single journey = %.2f\n\n", singlecost);
scanf("%f", &singlecost);
}
else if (choice==2)
{
printf("\nprice of return journey = %.2f\n\n", returncost);
scanf("%f", &returncost);
}
else
{
printf("\nInvalid Option");
}
getchar();
return 0;
}
}
}