NewProgrammer61711
New member
- Joined
- Nov 7, 2021
- Messages
- 1
- Programming Experience
- Beginner
The Victoria line has these stations in the following order: Brixton, Stockwell, Vauxhall, Pimlico, Victoria, Green Park, Oxford Circus, Warren Street, Euston, King's Cross, Highbury & Islington, Finsbury Park, Seven Sisters, Tottenham Hale, Blackhorse Road and Walthamstow Central.
Write a program that allows the user to input two stations. It should then output the number of stops between the two stations. The station names can be input in any order, but you can make the problem easier by only inputting stations in the correct order if you need to.
Attempt:
Write a program that allows the user to input two stations. It should then output the number of stops between the two stations. The station names can be input in any order, but you can make the problem easier by only inputting stations in the correct order if you need to.
Attempt:
C#:
using System;
using System.Collections.Generic;
namespace arrayslist
{
public class Program
{
public static void Main(string[] args)
{
//Main program
int two = 0;
int one = 0;
string[] stop = new string[16];
stop[0] = "Brixton";
stop[1]= "Stockwell";
stop[2] = "Pimlico";
stop[3] = "Vauxhall";
stop[4] = "Victoria";
stop[5]= "Green Park";
stop[6] = "Oxford Circus";
stop[7] = "Warren Street";
stop[8] = "Euston";
stop[9] = "King's Cross";
stop[10] = "Highbury & IslingtoN";
stop[11]= "Finsbury Park";
stop[12]= "Seven Sisters";
stop[13] = "Tottenham Hale";
stop[14] = "Blackhorse Road";
stop[15] = "Walthamstow Central";
Console.WriteLine("What is your first stop?");
string st1 = Console.ReadLine();
Console.WriteLine("What is your second stop?");
string st2 = Console.ReadLine();
if (st1 == "Brixton" && st2 == "Stockwell")
{
Console.WriteLine(Array.IndexOf(stop, "Brixton"));
// (Line 46) one = Console.ReadLine();
}
Last edited by a moderator: