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
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)
So pretty much I need my code without the arrays, or lists. Please and thank you!...
So pretty much I need my code without the arrays, or lists. Please and thank you! Important: You may not use arrays, lists, or similar for your questions. This will be covered in the next module. The objective is to use conditionals in order to achieve the overall task. Checkpoint 3 is a continuation of the “Quiz” Programming Project. This module week, you will implement repetitive tasks in your program while using conditional and iteration statements in C#. Implement a...
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,...
For this question you will need to upload a file. It is question 3 from the...
For this question you will need to upload a file. It is question 3 from the PDF file I sent you. Please show your work. The following information is given about the market for a normal good. Demand: P = 150-2Qd Supply P = 20+ 0.5 Qs What is the quantity demanded at a price of $80? (1.5 mark) What is the quantity supplied at a price of $80? (1.5 mark) At a price of $80 the market is not...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT