Create a program for Smalltown Regional Airport Flights that accepts either an integer flight number or string airport code from the options in Figure 8-33. Pass the user’s entry to one of two overloaded GetFlightInfo() methods, and then display a returned string with all the flight details. For example, if 201 was input, the output would be: Flight #201 AUS Austin Scheduled at: 0710 (note that there should be two spaces between 'Austin' and 'Scheduled'). The method version that accepts an integer looks up the airport code, name, and time of flight; the version that accepts a string description looks up the flight number, airport name, and time. The methods return a message if the flight is not found. For example, if 100 was input, the output should be Flight #100 was not found. If no flights were scheduled for the airport code entered, for example MCO, the message displayed should be Flight to MCO was not found. Here is my code, and I am having this error "1-Flights.GetFlightInfo(string, int[], string[], string[], string[])': not all code paths return a value Compilation failed: 1 error(s)". For this line if (code != codes[x]) I am having error that string cannot be compared like this. How do we write a statement if 2 strings are not equal?

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Microsoft Visual C# 7th  edition

Create a program for Smalltown Regional Airport Flights that accepts either an integer flight number or string airport code from the options in Figure 8-33.

Pass the user’s entry to one of two overloaded GetFlightInfo() methods, and then display a returned string with all the flight details. For example, if 201 was input, the output would be: Flight #201 AUS Austin Scheduled at: 0710 (note that there should be two spaces between 'Austin' and 'Scheduled').

The method version that accepts an integer looks up the airport code, name, and time of flight; the version that accepts a string description looks up the flight number, airport name, and time.

The methods return a message if the flight is not found. For example, if 100 was input, the output should be Flight #100 was not found.

If no flights were scheduled for the airport code entered, for example MCO, the message displayed should be Flight to MCO was not found.

Here is my code, and I am having this error "1-Flights.GetFlightInfo(string, int[], string[], string[], string[])': not all code paths return a value
Compilation failed: 1 error(s)".

For this line if (code != codes[x]) I am having error that string cannot be compared like this. How do we write a statement if 2 strings are not equal?

 

using System;
using static System.Console;
class Flights
{
   static void Main()
   {
      // Write your main here
      int flight;
      string flightCode;
      int[] flightNumbers = {201, 321, 510, 633};
      string[] codes = {"AUS", "CRP", "DFW", "HOU"};
      string[] names = {"Austin", "Corpus Christi", "Dallas Fort Worth", "Houston"};
      string[] times = {"0710", "0830", "0915", "1140"};
      WriteLine("Enter flight number, the correct number are 201, 321, 510, 633");
      flightCode = ReadLine();
      flight = Convert.ToInt32(flightCode);
      GetFlightInfo(flight, flightNumbers, codes, names,  times);
      
   }
    
   public static string GetFlightInfo(int flight, int[] flightNumbers, string[] codes, string[] names, string[] times)
   {
     
     
     int x=0;
     for(x=0; x > flightNumbers.Length; ++x)
     {
      if(flight==flightNumbers[x])
      {
        
      return "Flight # {0}{1}{2,2} Scheduled at: {3}" + flightNumbers[x] + codes[x]+names[x]+times[x];
      }
      else
      WriteLine("Flight # {0} was not found", flight);}
      //flightNumber = Convert.Tostring(flightNumbers[x]);
      return"Flight # was not found" + flight;
   }   
  
   public static string GetFlightInfo(string code, int[] flightNumbers, string[] codes, string[] names, string[] times)
   {
    WriteLine("enter airport code; correct code are AUS, CRP, DFW, HOU");
    code = ReadLine();
    int x=0;
    for(x=0; x> codes.Length;++x)
     
      code.Equals(codes);
      if(code.ToUpper().Equals(codes[x]))
      return "Flight # {0}{1}{2,2} Scheduled at: {3}" + flightNumbers[x] + codes[x]+names[x]+times[x];;
      if (code != codes[x])
      return "Flight to {0} was not found."+ code;
       
   }

}



 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY