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

Read a text file into arrays and output - Java Program ------------------------------------------------------------------------------ I need to have...
Read a text file into arrays and output - Java Program ------------------------------------------------------------------------------ I need to have a java program read an "input.txt" file (like below) and store the information in an respective arrays. This input.txt file will look like below and will be stored in the same directory as the java file. The top line of the text represents the number of people in the group for example. the lines below it each represent the respective persons preferences in regards...
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
You will need to use only two arrays:  One array of type int to store...
You will need to use only two arrays:  One array of type int to store all the ID's  One two‐dimensional array of type double to store all the scores for all quizzes Note: The two dimensional array can be represented also with the rows being the students and the columns being the quizzes. How to proceed: 1. Declare the number of quizzes as a constant, outside the main method. (Recall that identifiers for constants are all in CAPITAL_LETTERS.)...
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...
Matrix multiplication with arrays In this question you will verify that the numpy.ndarray matrix multiplication operator,...
Matrix multiplication with arrays In this question you will verify that the numpy.ndarray matrix multiplication operator, @, does a proper matrix multiplcation. To do this, first write a function, mat_mult(a1, a2) that creates a new 2d array of zeros, and using nested for loops, fill in the elements of the matrix multiplication, and return this new array. Then, write a second function, matrix_diff(b, c) that takes two arrays as arguments then generates and returns the following ratio: sqrt((∑(??,?−??,?)^2)/(∑(??,?+??,?)^2)) This function...
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)
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT