Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Help on College Assignment

Options
  • 30-04-2018 1:36pm
    #1
    Registered Users Posts: 10


    Hello everyone,

    I have an assignment that is due this Thursday, I am stuck on this part of the question and I've been trying to work it for the last 4 days and I got nothing out of this. It's causing me stress and I can't get it done.

    Right here I have the question that is asking me to do and a form of people's name. Can anyone help me on coding this? I'm struggling badly on programming this year and I want to pass it in order to be able to move onto Computer Science and Networking.

    Thanks.

    Capture.PNG

    FrenchMF.TXT


Comments

  • Registered Users Posts: 3,945 ✭✭✭Anima


    You should have probably posted your attempt at it or even how you think it's supposed to be solved otherwise it looks like you're just asking for the answer.

    You have to iterate through the list of ships in the file, determine which location matches which sea and group each ship into one of those 5 categories no?

    Printing out the report is simply a case of writing a function that writes out the text as given in the question and you supply the count for each sea by the size of the array of each grouping earlier (or whatever data structure you use).


  • Closed Accounts Posts: 3,596 ✭✭✭threein99


    Which part of the strings in the file represents the sea the Vessel is in? is it the last digit ?

    Clémentine,1,100326,5498,1
    Vénus,1,100480,5357,1
    Dù,2,55175,3152,1
    Angélique,1,100502,5052,2
    Annotée,1,100300,5426,3

    I presume the Pacific is number 1, Atlantic number 2 and the Med number 3 etc etc ?


  • Registered Users Posts: 27,163 ✭✭✭✭GreeBo


    What language?

    As above, can you share anything you have done this far?


  • Registered Users Posts: 10 MidnightVibes


    Sorry if I made it look like I was asking for someone to do it for me but here's all my work so far and this is also the assignment form telling me what I have to do.
    This is the most difficult assignment I've ever come across and I'm really slow at trying to understand how to work it out. Can anyone help?

    Capture.PNG

    Capture2.PNG

    Capture3.PNG

    c#_sem2_Assignment2.docx


  • Registered Users Posts: 10 MidnightVibes


    The number after the name represent the vessel numbers.


  • Advertisement
  • Registered Users Posts: 3,945 ✭✭✭Anima


    What part are you having trouble with?

    You're reading the file but just printing each line. You should be storing that info into a class/data structure and then you can perform your analysis on the array of records. Like looping through to find all of one type of category.


  • Registered Users Posts: 6,171 ✭✭✭Talisman


    There's a syntax error in costPerCrew().
    int crewCostp2 = crewCost(vessels - 1);
    

    should be:
    int crewCostp2 = crewCost[vessels - 1];
    

    Use square brackets because you are accessing an array not calling a function.


  • Registered Users Posts: 10 MidnightVibes


    Anima wrote: »
    What part are you having trouble with?

    You're reading the file but just printing each line. You should be storing that info into a class/data structure and then you can perform your analysis on the array of records. Like looping through to find all of one type of category.

    All of "location analysis report" because I can't seem to understand the question or know how to start it, I've made the read file but don't know how to work it in the report section


  • Closed Accounts Posts: 3,596 ✭✭✭threein99


    All of "location analysis report" because I can't seem to understand the question or know how to start it, I've made the read file but don't know how to work it in the report section

    Try and break the problem down. I find writing out what I'm trying to achieve in clear English helps when I am stuck.

    I haven't used C# that much I mainly use Python these days.

    But I think you need to store each line of the file in a data structure like a array or arrays so you can count the number of vessels in each Ocean.

    So then loop through the list/array and count each occurrence of number 1 for the Pacific number 2 for the Atlantic and so on.


  • Registered Users Posts: 6,171 ✭✭✭Talisman


    Your first problem is that you aren't storing the data read from the file, you are simply dumping it to the screen.

    Create a class to store the data.
    class VesselDetails
    {
       public string VesselName { get; set; }
       public int VesselType { get; set; }
       public int Tonnage { get; set; }
       public int Crew { get; set; }
       public int LocationCode { get; set; }
    }
    

    When you read the contents of 'FVMF.txt' you will need to create an instance of the class for each row of the file. You'll need to create a container to store these instances of this class. The 'readFile()' method should return the container that has been populated with your data.

    If you were to use an array as the container for storing the instances of VesselDetails then the report is simply a case of iterating through the container and picking out the vessels that meet the requirements. You might even want an array for each of your locations.

    This should be enough information for you to complete the assignment yourself.


  • Advertisement
  • Registered Users Posts: 10 MidnightVibes


    Here's the update. I got everything done except for name searching. I cannot seem to find the solution for it to work. Any suggestion?

    Capture.PNG

    Capture2.PNG


  • Closed Accounts Posts: 3,596 ✭✭✭threein99


    Here's the update. I got everything done except for name searching. I cannot seem to find the solution for it to work. Any suggestion?

    Capture.PNG

    Capture2.PNG

    I'm not seeing where you are populating the vesselInfo array with data ? print the contents of vesselInfo[0]


  • Registered Users Posts: 3,945 ✭✭✭Anima


    You shouldn't be reading in the file again. Just read it in once at the start. When it's in memory, you can do whatever you want with the data.


  • Registered Users Posts: 6,171 ✭✭✭Talisman


    Here's the update. I got everything done except for name searching. I cannot seem to find the solution for it to work. Any suggestion?
    Have you looked at Microsoft's C# Guide? There are two pages that will help you: Search strings and How to compare strings in C#.


  • Posts: 0 [Deleted User]


    Just a heads up to the OP..... Your lecturers name is in the Doc files details and with the whole "no plagarism thing" you should probably take the document down if you dont to get in trouble. Just for your own sake incase you might get in trouble.


Advertisement