Question

In: Computer Science

Arrays Question: You need to read in and process the wind speeds in East London over...

Arrays Question:
You need to read in and process the wind speeds in East London over the past few days. The maximum number of days are 8. Implement the methods listed below. Then use these methods effectively to read in the marks wind speeds and display the minimum and maximum speeds. You may not change any methods – including their parameters. static public int getValidNumber(int a, int b)
//Returns a number between a and b – including a and b
//You may assume that a <= b static public void ReadSpeedsIntoArray (int[] list, ref int NrEl)
// Reads wind speeds into an array. Request from the user how many
// wind speeds need to be read in. At least 4 speeds must be read
// in, but not more than 10. A speed cannot be negative or higher
// than 150. static public void getMinMax (int[] list, int NrEl, out int Min, out int Max )
// Returns the minimum and the maximum wind speed recorded in list static public void displayMinMax (int[] list, int NrEl)
// Displays the minimum and maximum wind speeds recorded in list

it's C# language

Solutions

Expert Solution

PLEASE GIVE IT A THUMBS UP, I SERIOUSLY NEED ONE, IF YOU NEED ANY MODIFICATION THEN LET ME KNOW, I WILL DO IT FOR YOU

Code:

using System;

public class MainClass {

  static public int getValidNumber(int a, int b)

  {

    Random r = new Random();

    int number = r.Next(a, b);

    return number;

  }

  static public void ReadSpeedInttoArray(int[] list, ref int NrEl)

  {

    int n;

    do

    {

      Console.WriteLine("How many readings(min 4)");

      n = Convert.ToInt32(Console.ReadLine());

      if (n > 8)

      {

        Console.WriteLine("number of readings cannot be more than 8");

      }

      if (n < 4)

      {

        Console.WriteLine("Please enter readings 4 or more");

      }

    } while ( n < 4 || n > 8 );

    for (int i = 0; i < n; i++)

    {

      list[i] = getValidNumber(0, 150);

    }

    NrEl = n;

  }

  static public void getMinMax(int[] list, int NrEl, out int min, out int max)

  {

    min = list[0];

    max = list[0];

    for (int i = 0; i < NrEl; i++)

    {

      if (max < list[i])

      {

        max = list[i];

      }

      if (min > list[i])

      {

        min = list[i];

      }

    }

  }

  static public void diplayMinMax(int[] list, int NrEl)

  {

    Console.WriteLine("List of Windspeeds: ");

    for (int i = 0; i < NrEl; i++)

    {

      Console.Write("{0} ", list[i]);

    }

    int min,
    max;

    getMinMax(list, NrEl, out min, out max);

    Console.WriteLine("\n\nMinimum windspeed : {0}", min);

    Console.WriteLine("\nMaximum windspeed: {0}", max);

  }

  public static void Main(string[] args) {

    int[] list = new int[8];

    int n = 0;

    ReadSpeedInttoArray(list, ref n);

    diplayMinMax(list, n);

  }

}

Output:


Related Solutions

I need answer for this question: Capital Budgeting This chapter goes over the Capital Budgeting process....
I need answer for this question: Capital Budgeting This chapter goes over the Capital Budgeting process. Capital Budgeting will help firms identify profitable projects so it can earn a return. Why? If a firm wants to stay viable, it will need to invest and innovate to stay ahead of its competition which is also investing and innovating. The question then becomes, what is the most cost effective and profitable way to invest the firm's scarce resources? Capital Budgeting attempts to...
You will need to read through the lab procedure and background information to solve this question....
You will need to read through the lab procedure and background information to solve this question. Need help? See a TA or your instructor in office hours. CaCrO4 is a slightly soluble solid. In the lab, you find that addition of 357.73 µL of 1 M H2CrO4 to 7.924 mL of 0.3 M Ca(NO3)2 results in formation of a persistent precipitate. Addition of water (1.878 mL) just dissolves the precipitate. What is the experimental value of Ksp for CaCrO4 according...
You may need to use the appropriate technology to answer this question. Based on sales over...
You may need to use the appropriate technology to answer this question. Based on sales over a six-month period, the five top-selling compact cars are Chevy Cruze, Ford Focus, Hyundai Elantra, Honda Civic, and Toyota Corolla.† Based on total sales, the market shares for these five compact cars were Chevy Cruze 24%, Ford Focus 21%, Hyundai Elantra 20%, Honda Civic 18%, and Toyota Corolla 17%. Suppose a sample of 400 compact car sales in one city showed the following number...
Please, read the question carefully. I need correct answers and clear explanation. Thank you! On Sept...
Please, read the question carefully. I need correct answers and clear explanation. Thank you! On Sept 15, 2017, Julia Inc entered into a contract to provide 12 new deep fryers to a Montreal Poutinerie. Julia normally charges $1,500 for each deep fryer. As part of the agreement, Julia will provide on-site training at the Poutinerie’s 3 locations. Julia will host 3 separate training sessions at each location. For this training, Julia normally charges $700 / day. The Poutinerie needed Julia’s...
Look at Table 5.2 – read over the often used nondimensional groups. No need to memorize...
Look at Table 5.2 – read over the often used nondimensional groups. No need to memorize these but they might provide a guide as to what Pi groups should appear in a problem
Parallel Arrays This question is in MindTap Cengage Summary In this lab, you use what you...
Parallel Arrays This question is in MindTap Cengage Summary In this lab, you use what you have learned about parallel arrays to complete a partially completed C++ program. The program should: Either print the name and price for a coffee add-in from the Jumpin’ Jive Coffee Shop Or it should print the message Sorry, we do not carry that. Read the problem description carefully before you begin. The file provided for this lab includes the necessary variable declarations and input...
Given two String arrays (named below), write the code that you would need in order to...
Given two String arrays (named below), write the code that you would need in order to copy the data from relatives into weddingInvitations in java. 1. relatives (which is loaded with data) 2. weddingInvitations (that is the same size as relatives)
Using Python read dataset in the HTML in beautiful way. You need to read CSV file...
Using Python read dataset in the HTML in beautiful way. You need to read CSV file ( Use any for example, You can use small dataset) You need to use pandas library You need to use Flask Make search table like YouTube has.
A road heading due east passes over a small hill. You drive a car of mass...
A road heading due east passes over a small hill. You drive a car of mass mat constant speed over the top of the hill, where the shape of the roadway is well approximated as an arc of a circle with radius R. Sensors have been placed on the road surface there to measure the downward force that cars exert on the surface at various speeds. The table gives values of this force versus speed for your car is shown...
During and after the commissioning and turn-over process, the design and construction team need to provide...
During and after the commissioning and turn-over process, the design and construction team need to provide the owner with many important documents for the operation of the building. These include all of the following, except: A list of things that the contractor secretly left out of the building to save costs. Operations and maintenance manuals for installed equipment Final construction drawings, typically called "As Built" drawings. These incorporate any minor changes made during construction. Design calculations for building systems. Warranty,...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT