Question

In: Computer Science

IN C# lang Write a console app (review Module 5 for console app) that stores 3...

IN C# lang

Write a console app (review Module 5 for console app) that stores 3 students test stores in 3 separate arrays as integers. Some did not not take all the tests, so they each have a their own length and we use separate arrays.

Declare and initialize each array. Use meaningful names.

Print each array as follows:

Morgan 98, 72, 65
Bowie 15, 47, 35, 92, 94
Ananya 91, 68, 87, 75

Extra credit: Compute the average for each with reusable code (do not have 3 separate pieces of code for the average) This is worth up to 3 points.

Extra extra credit: Ask the user to input the test scores. This is worth up to 2 points.

Submit zipped file. File name is

LastName_M07_ArrayBasics.zip

Solutions

Expert Solution

using System;

class MainClass {

    public static double avg(int[] arr) {
        double sum = 0;
        for(int i=0; i<arr.Length; i++) {
            sum += arr[i];
        }
        return sum/arr.Length;
    }

    public static void Main (string[] args) {
        string[] names = { "Morgan" , "Bowie", "Ananya" };
        int[] score1 = {98, 72, 65};
        int[] score2 = {15, 47, 35, 92, 94};
        int[] score3 = {91, 68, 87, 75};

        Console.WriteLine("Average of " + names[0] + " is " + avg(score1));
        Console.WriteLine("Average of " + names[1] + " is " + avg(score2));
        Console.WriteLine("Average of " + names[2] + " is " + avg(score3));


    }
}


Please upvote, as i have given the exact answer as asked in question. Still in case of any concerns in code, let me know in comments. Thanks!


Related Solutions

In C# using a Console App, create an array that stores 20 integer values. Use the...
In C# using a Console App, create an array that stores 20 integer values. Use the random number generator to select an integer value between 0 and 10. Store the 20 random integers in the array. Once the array has been created: Print the values in the array. Print the values in the array in reverse order. Sort and print the values in the array in ascending order. Sort and print the values in the array in descending order. Count...
write a c# console application app that reads all the services in the task manager and...
write a c# console application app that reads all the services in the task manager and automatically saves what was read in a Notepad txt file.  Please make sure that this program runs, also add some comments
Find MIN. Write a C# console app consisting of class MIN with the method CalculateMin() and...
Find MIN. Write a C# console app consisting of class MIN with the method CalculateMin() and the driver class. Print the MIN and MIN's location. Don't count numbers outside the range [0, 100].
write C# console app No arrays Credit card validation Problem. A credit card number must be...
write C# console app No arrays Credit card validation Problem. A credit card number must be between 13 and 16 digits. It must start with: –4 for visa cards –5 for mater cards –37 for American express cards –6 for discover cards •Consider a credit card number 4380556218442727 •Step1: double every second digit from right to left. If doubling of a digit results in a two-digit number, add up the two digits to get a single-digit number. •Step2: now add...
Create a console app with C# that uses a while loop to calculate the average of...
Create a console app with C# that uses a while loop to calculate the average of 3 test scores. Input integers, but use the appropriate average data type. Generally, you use a while to do something while a condition is true. You can use a while loop to execute a certain number of times. *While* this is not the best use of the while loop and another loop is generally more appropriate, it follows the pattern below set a counter...
Create a console app c#. Using a List, ask the user to enter all of their...
Create a console app c#. Using a List, ask the user to enter all of their favorite things. Once they are done, randomly pick a value from the list and display it.
Shopping Cart App (C#) Please create a C# Console (.NET Framework) application which reads from the...
Shopping Cart App (C#) Please create a C# Console (.NET Framework) application which reads from the user, the price of items in their shopping "cart". Be sure to tell the user how to stop (or ask them if they want to stop) entering prices. Items can be priced any positive number greater than zero. When the user has entered the prices for all items in their "cart", calculate the subtotal (the sum of all item prices). Next, check if the...
Needs to be written in C# Console App! Create a base class BankAccount. Decide what characteristics...
Needs to be written in C# Console App! Create a base class BankAccount. Decide what characteristics are common for checking and saving accounts and include these characteristics in the base class. Define derived classes for checking and savings. In your design , do not allow the banking base account to be instantiated --only the checking and saving classes. Use a Program class to test your design.
C# Programming Language Write a C# program ( Console or GUI ) that prompts the user...
C# Programming Language Write a C# program ( Console or GUI ) that prompts the user to enter the three examinations ( test 1, test 2, and test 3), homework, and final project grades then calculate and display the overall grade along with a message, using the selection structure (if/else). The message is based on the following criteria: “Excellent” if the overall grade is 90 or more. “Good” if the overall grade is between 80 and 90 ( not including...
Programming lang C++ Write a program that reads 10,000 words into an array of strings. The...
Programming lang C++ Write a program that reads 10,000 words into an array of strings. The program will then read a second file that contains an undetermined number of words and search the first array for each word. The program will then report the number of words in the second list that were found on the first list.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT