Question

Please code using C# Complete the two methods, highest() and lowest(). Both methods are static with...

Please code using C#

Complete the two methods, highest() and lowest().

  • Both methods are static with a double return type and one integer parameter.
  • Both methods will accept user input of as many numbers as the integer parameter’s value.
  • The highest() method will return the largest number input.
  • The lowest() method will return the smallest number input.

Examples:

The call highest(3) with user inputs of [5, 60, 2] will return the value of 60

The call lowest(3) with user inputs of [20, 10, 5] will return the value of 5

Homework Answers

Answer #1
using System;
class HelloWorld {
  static void Main() {
      int []arr={5, 60, 2};
    Console.WriteLine(highest(arr));
    Console.WriteLine(lowest(arr));
    
  }
  static double highest(int [] arr){
      int max=arr[0];
      for(int i=1;i<arr.Length;i++){
          if(max<arr[i])
            max=arr[i];
      }
      return max;
  }
  static double lowest(int [] arr){
      int min=arr[0];
      for(int i=1;i<arr.Length;i++){
          if(min>arr[i])
            min=arr[i];
      }
      return min;
  }
  
}

NOTE : PLEASE COMMENT BELOW IF YOU HAVE CONCERNS.

I AM HERE TO HELP YOUIF YOU LIKE MY ANSWER PLEASE RATE AND HELP ME IT IS VERY IMP FOR ME

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
PLease code a C++ program that prompts a user to enter 10 numbers. this program should...
PLease code a C++ program that prompts a user to enter 10 numbers. this program should read the numbers into an array and find the smallest number in the list, the largest numbers in the list the sum of the 10 numbers and the average of the 10 numbers please use file i/o and input measures for Handling Errors in C++ When Opening a File
C CODE PLZ! All instructions are in sections of code #include <stdio.h> /* TODO: Define 3...
C CODE PLZ! All instructions are in sections of code #include <stdio.h> /* TODO: Define 3 functions input, gcd and lcm in such a way that the main function below compiles correctly and has the correct behavior. The input function prompts the user to enter a non-negative integer. If the user enters a negative integer, the function prints a "sorry" statement and prompts the user again. It keeps on prompting until the user enters a non-negative number. The input function...
Consider the following two methods: public static boolean isTrue(int n){        if(n%2 == 0)          ...
Consider the following two methods: public static boolean isTrue(int n){        if(n%2 == 0)           return true;        else           return false; } public static int Method(int[] numbers, int startIndex) { if(startIndex >= numbers.length)        return 0; if (isTrue(numbers[startIndex]))      return 1 + Method(numbers, startIndex + 1); else      return Method(numbers, startIndex + 1); } What is the final return value of Method() if it is called with the following parameters: numbers = {1, 2, 2, 3, 3,...
PLEASE DO IT IN C++ ONLY. THE MIN-MAX DIGIT PROBLEM Write a function named minMaxDigit() that...
PLEASE DO IT IN C++ ONLY. THE MIN-MAX DIGIT PROBLEM Write a function named minMaxDigit() that accepts an integer as an input parameter and returns the largest and smallest digits using the two output parameters min and max. For example, the call minMaxDigit(68437, min, max) would set min to 3 and max to 8. If there is only one digit, then both min and max are set to the same value. The function has no return statement.
Create a class named MyTriangle that contains the following three methods: public static boolean isValid(double sidea,...
Create a class named MyTriangle that contains the following three methods: public static boolean isValid(double sidea, double sideb, double sidec) public static double area(double sidea, double sideb, double sidec) public static String triangletType(double a, double b, double c) The isValid method returns true if the sum of the two shorter sides is greater than the longest side. The lengths of the 3 sides of the triangle are sent to this method but you may NOT assume that they are sent...
2.13 LAB: Driving cost - methods Write a method drivingCost() with input parameters drivenMiles, milesPerGallon, and...
2.13 LAB: Driving cost - methods Write a method drivingCost() with input parameters drivenMiles, milesPerGallon, and dollarsPerGallon, that returns the dollar cost to drive those miles. All items are of type double. If the method is called with 50 20.0 3.1599, the method returns 7.89975. Define that method in a program whose inputs are the car's miles/gallon and the gas dollars/gallon (both doubles). Output the gas cost for 10 miles, 50 miles, and 400 miles, by calling your drivingCost() method...
Java Code import java.util.Scanner; /** Create two methods as instructed below and then call them appropriately....
Java Code import java.util.Scanner; /** Create two methods as instructed below and then call them appropriately. Hint: Only one of the methods you create needs to be called from the main method. */ public class LandCalculation { public static void main(String[] args) { final int FEET_PER_ACRE = 43560; // Number of feet per acre double tract = 0.0, acres = 0.0; Scanner keyboard = new Scanner(System.in); System.out.print("Enter the tract size: "); tract = keyboard.nextDouble(); // Validate the user's input. while(tract...
Practice manipulating an object by calling its methods. Complete the class Homework1 class using String methods....
Practice manipulating an object by calling its methods. Complete the class Homework1 class using String methods. Remember that all the String methods are accessors. They do not change the original String. If you want to apply multiple methods to a String, you will need to save the return value in a variable. Complete the class by doing the following: + Print the word in lowercase + Replace "e" with "3" (Use the unmodified variable word) + Print the changed word...
[Java] I'm not sure how to implement the code. Please check my code at the bottom....
[Java] I'm not sure how to implement the code. Please check my code at the bottom. In this problem you will write several static methods to work with arrays and ArrayLists. Remember that a static method does not work on the instance variables of the class. All the data needed is provided in the parameters. Call the class Util. Notice how the methods are invoked in UtilTester. public static int min(int[] array) gets the minimum value in the array public...
Use C++ to implement the following program about Prime Factorization of a Number. Do BOTH parts...
Use C++ to implement the following program about Prime Factorization of a Number. Do BOTH parts of the problem or you will lose points. Provide comments to explain each step. a. Write a function that takes as a parameter a positive integer and returns a list (array) of the prime factors of the given integer. For example, if the parameter is 20, you should return 2 2 5. b. Write a function that tests the above function by asking the...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT