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.  I am having these errors  1- Flights.GetFlightInfo(string, int[], string[], string[], string[])': not all code paths return a value Compilation failed: 1 error(s)". What does that mean and how will I fix it? 2- How to write a code to return a string? 3- What an overloaded method mean, and how to write it?

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter8: Arrays
Section: Chapter Questions
Problem 3PE
icon
Related questions
Question
100%

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.

 I am having these errors 

1- Flights.GetFlightInfo(string, int[], string[], string[], string[])': not all code paths return a value
Compilation failed: 1 error(s)". What does that mean and how will I fix it?

2- How to write a code to return a string?

3- What an overloaded method mean, and how to write it? thank you.

Here is my code

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)
   {
     
     string flightNumber;
     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 flightNumber;
      //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 (String.Compare(code,codes[x])!=0)
      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 3 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT