Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I. Edit, compile, and run the following program on the UNIX shell: A. Rcad a Mor

ID: 3599752 • Letter: I

Question

I. Edit, compile, and run the following program on the UNIX shell: A. Rcad a Morsc Code phrasc from the commandlinc and decode the phrasc into English. B. Check to makc sure the user entered at lcast 2 commandlinc arguments. If not, print crror messagc and end program. C. Do NOT usc scanf) or getchar for input for this program. The input for this program is ONLY from the commandlinc D. Usc string functions to compare strings, takc the length of thc string, add to a string, ctc. 1. At a minimum, you nced two ncsted for loops, and the strempO function to comparc the argvL array to the morscll array. 2. Functions strncpy0, strncat, strcmp), strstr), and strtok) might also bc uscful for this assignment, as there are many different ways to writc thc codc for this assignment 3. Hcrc is somc cxample codc to give you an idca about how to acccss thc Morsc codc array. Thc variable i is the index in a loop printf( "complete string %s ", morse [i]); printf("first charactercin", morse[i] Io]) printf( "Morse code part %s ", morse [1]+2); printf("Morse code length »d ", strlen (morse[i])-3) E. Please use loops, instead of 36 if-statements or 36 case-statements.

Explanation / Answer

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Programs
{
    public class Student
    {
        public string First { get; set; }
        public string Last { get; set; }
        public int ID { get; set; }
        public List<int> Marks;
        public ContactInfo GetContactInfo(Programs pg, int id)
        {
            ContactInfo allinfo =
                (from ci in pg.contactList
                 where ci.ID == id
                 select ci)
                .FirstOrDefault();


            return allinfo;
        }


        public override string ToString()
        {
            return First + "" + Last + " : "   + ID;
        }
    }


    public class ContactInfo
    {
        public int ID { get; set; }
        public string Email { get; set; }
        public string Phone { get; set; }
        public override string ToString() { return Email + "," + Phone; }
    }


    public class ScoreInfo
    {
        public double Average { get; set; }
        public int ID { get; set; }
    }
    List<Student> students = new List<Student>()
        {
             new Student {First="Tom", Last=".S", ID=1, Marks= new List<int>() {97, 92, 81, 60}},
             new Student {First="Jerry", Last=".M", ID=2, Marks= new List<int>() {75, 84, 91, 39}},
             new Student {First="Bob", Last=".P", ID=3, Marks= new List<int>() {88, 94, 65, 91}},
             new Student {First="Mark", Last=".G", ID=4, Marks= new List<int>() {97, 89, 85, 82}},
        };
    List<ContactInfo> contactList = new List<ContactInfo>()
        {
            new ContactInfo {ID=111, Email="Tom@abc.com", Phone="9328298765"},
            new ContactInfo {ID=112, Email="Jerry123@aaa.com", Phone="9876543201"},
            new ContactInfo {ID=113, Email="Bobstar@aaa.com", Phone="9087467653"},
            new ContactInfo {ID=114, Email="Markantony@qqq.com", Phone="9870098761"}
        };


    static void Main(string[] args)
    {
        Programs pg = new Programs();


        IEnumerable<Student> studentQuery1 =
            from student in pg.students
            where student.ID > 1
            select student;


        Console.WriteLine("Query : Select range_variable");
        Console.WriteLine("Name    : ID");
        foreach (Student s in studentQuery1)
        {
            Console.WriteLine(s.ToString());
        }
        Console.ReadLine();
    }
}