Joe Collins

Joe Collins

  • NA
  • 1
  • 1.2k

Struggling with basic errors C#

Mar 25 2013 12:38 PM
Hi all,

I'm very new to C# and I've currently just 'completed' a bit of code however I've been left with 7 errors that I can't seem to get rid of!

Here is my code - I realise it is very basic and apologies if I have not provided all the information. Like I said, I'm new :)
All errors are in bold.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _250213
{
    class Journey
    {
        private string JourneyDate;
        private string JourneyStart;
        private string JourneyEnd;
        private string JourneyDistance;
        private string JourneyFuelUsed;
        private string JourneyPurpose;
        
        public Journey(string JourneyDate, string JourneyStart, string JourneyEnd, string JourneyDistance, string JourneyFuelUsed, string JourneyPurpose)
        {
            JourneyDate = date;
            JourneyStart = start;
            JourneyEnd = end;
            JourneyDistance = distance;
            JourneyFuelUsed = fuelused;
            JourneyPurpose = purpose;
            //lists all the components i'm going to have for the Journey



        }
        public string TellMe()
        {
            return "Journey #" + (+1) + "was on" + JourneyDate + "."
            + " The journey started on " + JourneyStart + "."
            + " It ended on " + JourneyEnd + "."
            + " It was " + JourneyDistance + "miles."
            + " The fuel used was" + JourneyFuelUsed + "gallons."
            + " The purpose of this particular journey was " + JourneyPurpose + ".";
        
        } //this is what it going to be outputted by the app once the user has submitted all the information. The + JourneyColour etc is where the users informaiton
    }


    class Program
    {
        static void Main(string[] args)
        {
            int numJourneys;
            String response;

            String JourneyDate;
            String JourneyStart;
            String JourneyEnd;
            String JourneyDistance;
            String JourneyFuelUsed;
            String JourneyPurpose;
           
            response = Questions(response, out numJourneys, out JourneyDate, out JourneyStart, out JourneyEnd, out JourneyDistance, out JourneyFuelUsed, out JourneyPurpose); //gives full information about the Journey




            Journey[] myJourneyArray = new Journey[numJourneys];
            for (int i = 0; i < myJourneyArray.Length; i++)
            {
                myJourneyArray[i] = new Journey(JourneyDate + i.ToString(), JourneyStart + i.ToString(), JourneyEnd + i.ToString(), JourneyDistance + i.ToString(), JourneyFuelUsed + i.ToString(), JourneyPurpose + i.ToString());
            }

            for (int i = 0; i < myJourneyArray.Length; i++)
            {
                Console.WriteLine(myJourneyArray[i].TellMe());
            }

            Console.ReadLine(); //array to store the Journeys in




        }

        private static string Questions(String response, out int numJourneys, out String Journeydate, out String Journeystart, out String Journeyend, out String JourneyDistance, out String JourneyFuelUsed, out String JourneyPurpose)
        {
            do
            {
                Console.WriteLine("How many Journeys are there? "); //asks the question
                response = Console.ReadLine(); //reads the response given



            } while (!int.TryParse(response, out numJourneys));
            Console.Write("What is the model of Journey #" + (+1) + "? "); //asks question 
            Journeydate = Console.ReadLine(); //reads input from user

            Console.Write("What is the colour of Journey #" + (+1) + "? ");
            Journeystart = Console.ReadLine();

            Console.Write("What is the engine size of Journey #" + (+1) + "? ");
            Journeyend = Console.ReadLine();

            Console.Write("What is the fuel type of Journey #" + (+1) + "? ");
            JourneyDistance = Console.ReadLine();

            Console.Write("What is the mileage of Journey #" + (+1) + "? ");
            JourneyFuelUsed = Console.ReadLine();

            Console.Write("What is the nickname of Journey #" + (+1) + "? ");
            JourneyPurpose = Console.ReadLine();

          



            Journey myJourney = new Journey(Journeydate, Journeystart, Journeyend, JourneyDistance, JourneyFuelUsed, JourneyPurpose);

            string[] myStringArray = new string[5];
            Console.WriteLine(myJourney.TellMe());
            Console.ReadLine();
            return response; //the output from all the questions given
        }
    } //method of the string questions
}


Here are my requirements, please note I am only doing the first two bullets points to start with to see if I can get that working.
? Log a new journey that includes the following details:
o Date of journey
o Start Location
o End Location
o Distance (in miles)
o Amount of fuel used (in gallons)
o Purpose of Journey

? Output a list of journeys that have been entered so far

? Get a detailed on-screen report for a particular journey– The output should include a 
calculated fuel economy from the distance travelled and the fuel used.

? Get a tabular report of all journeys that have been entered. Each journey should be a row in 
the output – which should be formatted appropriately. An average fuel economy should be 
calculated for all journeys in addition to the economy of each individual journey.


Regards,
Joe

Answers (1)