Question

PLEASE DO IN C# AND MAKE SURE I CAN COPY COPY CODE INTO VISUAL STUDIO Now,...

PLEASE DO IN C# AND MAKE SURE I CAN COPY COPY CODE INTO VISUAL STUDIO

Now, complete the provided “main” method by calling the previous method (“SortArray”). Display the contents of your array before and after the method call. A simple example of the output is provided below: Arrays Values before Sorting: Value at: [0] is: 11 Value at: [1] is: 4 Value at: [2] is: 44 Value at: [3] is: 14 Value at: [4] is: 5 Sorted Arrays Values: Value at: [0] is: 4 Value at: [1] is: 5 Value at: [2] is: 11 Value at: [3] is: 14 Value at: [4] is: 44

0 0
Add a comment Improve this question Transcribed image text
Answer #1
using System;

public class SortArrayTest
{
    public static void SortArray(int[] myArr)
    {
        int temp;
        for (int i = 0; i < myArr.Length; ++i)
        {
            for (int j = 0; j < myArr.Length - 1; ++j)
            {
                if (myArr[j] > myArr[j + 1])
                {
                    temp = myArr[j];
                    myArr[j] = myArr[j + 1];
                    myArr[j + 1] = temp;
                }
            }
        }
    }

    public static void Main()
    {
        int[] arr = {11, 4, 44, 14, 5};
        Console.WriteLine("Arrays Values before Sorting:");
        for (int i = 0; i < arr.Length; ++i)
        {
            Console.WriteLine("Value at: [" + i + "] is: " + arr[i]);
        }

        SortArray(arr);
        Console.WriteLine("Sorted Arrays Values:");
        for (int i = 0; i < arr.Length; ++i)
        {
            Console.WriteLine("Value at: [" + i + "] is: " + arr[i]);
        }
    }
}



Add a comment
Know the answer?
Add Answer to:
PLEASE DO IN C# AND MAKE SURE I CAN COPY COPY CODE INTO VISUAL STUDIO Now,...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • URGENT ! PLEASE DO IN C# AND MAKE SURE I CAN COPY COPY CODE INTO VISUAL...

    URGENT ! PLEASE DO IN C# AND MAKE SURE I CAN COPY COPY CODE INTO VISUAL STUDIO Define a method named SortArray() to sort a one dimensional array of integers. YOU MAY NOT CALL A BUILT-IN SORTING FUNCTION, but should write your own. The method should return the sorted array. You may use whichever sorting algorithm you prefer, in order to sort the array. Please initialize an array and fill it with random values before beginning. Ensure that it has...

  • PLEASE DO IN C# AND MAKE SURE I CAN COPY CODE INTO VISUAL STUDIO Exercise #2:...

    PLEASE DO IN C# AND MAKE SURE I CAN COPY CODE INTO VISUAL STUDIO Exercise #2: Design and implement a program (name it CompareArrays) that compares the content of 2 single-dimensional arrays of the same size. The program prompts the users to enter the array size. Then prompts the user to initialize each array with integer values. The program defines method Compare() that takes two signal-dimensional arrays of type integer. The method compares the content of the arrays and returns...

  • PLEASE DO IN C# AND MAKE SURE I CAN COPY CODE IN VISUAL STUDIO Program 2:...

    PLEASE DO IN C# AND MAKE SURE I CAN COPY CODE IN VISUAL STUDIO Program 2: Design (pseudocode) and implement (source code) a program (name it FeetMeters) to display a conversion tables for feet and meter as show below. Document your code and properly. Feet Meter 1.0 0.305 2.0 0.610 3.0 0.915 . . . . . . 19.0 5.7.95 20.0 6.100 Meter Feet 1.0 3.279 2.0 6.558 3.0 9.837 . . . . . . 19.0 62.301 20.0 65.574...

  • PLEASE DO IN C# AND MAKE SURE I CAN COPY CODE INTO VISUAL STUDIO Program 4:...

    PLEASE DO IN C# AND MAKE SURE I CAN COPY CODE INTO VISUAL STUDIO Program 4: A palindromic prime number is a number that is both prime number and a palindrome number. For example, 131, 313, and 757 are palindromic prime numbers. Design (pseudocode) and implement (source code) a program (name it PalindromicPrime) to display the first 50 palindromic prime numbers, 10 per line separated by one space. The program defines the following methods: Method isPalindome() to check if a...

  • PLEASE DO IN C# AND MAKE SURE I CAN COPY CODE IN VISUAL STUDIO Exercise #1:...

    PLEASE DO IN C# AND MAKE SURE I CAN COPY CODE IN VISUAL STUDIO Exercise #1: Design and implement class Rectangle to represent a rectangle object. The class defines the following attributes (variables) and methods: 1. Two Class variables of type double named height and width to represent the height and width of the rectangle. Set their default values to 1.0 in the default constructor. 2. A non-argument constructor method to create a default rectangle. 3. Another constructor method to...

  • PLEASE DO IN C# AND MAKE SURE I CAN COPY CODE IN VISUAL STUDIO Program 2:...

    PLEASE DO IN C# AND MAKE SURE I CAN COPY CODE IN VISUAL STUDIO Program 2: Design (pseudocode) and implement (source code) a class called Counter. It should have one private instance variable representing the value of the counter. It should have two instance methods: increment() which adds on to the counter value and getValue() which returns the current value. After creating the Counter class, create a program that simulates tossing a coin 100 times using two Counter objects (Head...

  • PLEASE DO IN C# AND MAKE SURE I CAN COPY CODE INTO VISUAL STUDIO Exercise#1:DesignandimplementclassCircletorepresentacircleobject.Theclassdefinesthefollowingattributes(variables)andmethods: Aprivatevariableoftypedoublenamedradiustorepresenttheradius.Se

    PLEASE DO IN C# AND MAKE SURE I CAN COPY CODE INTO VISUAL STUDIO Exercise#1:DesignandimplementclassCircletorepresentacircleobject.Theclassdefinesthefollowingattributes(variables)andmethods: Aprivatevariableoftypedoublenamedradiustorepresenttheradius.Setto Constructor Methods: Python : Anoverloaded constructormethodtocreateadefaultcircle. C# & Java: Default Constructor with no arguments. C# & Java: Constructormethodthatcreatesacirclewithuser-specifiedradius. MethodgetRadius()thatreturnstheradius. MethodsetRadius()thatsetstheradius. MethodgetArea()thatreturnsthearea. MethodgetPerimeter()thatreturnstheperimeter. MethodtoString()toprintoutameaningfuldescriptionofthecircleasfollows: ThecirclehasradiusX.     WhereXisthevalueofvariableradius. Nowdesignandimplementatestprogramtocreateadefaultcircleobjectandtestallclassmethodsontheobject.Printtheobjectaftereachmethodcallandusemeaningfullabelforeachmethodcallasshowninthefollowingsamplerun. Samplerun: Printradius: Theradiusis1. Printarea: Theareais3.14 Printperimeter: Theperimeteris6.28 Setradiusto10andprinttheobject:Thecirclehasradius10. Printarea: Theareais314.23 Printperimeter: Theperimeteris62.81

  • In visual studio Populate a one-dimensional array with the following grades in this order: 90, 61,...

    In visual studio Populate a one-dimensional array with the following grades in this order: 90, 61, 74, 42, 83, 51, 71, 83, 98, 87, 94, 68, 44, and 66. Use a loop to call a method from main() that adds 15 points to all student grades that are a C or above. A C is defined as a score of 70 or above. Make this happen by passing the subscript value and not the entire array. The addition of the...

  • Hi i will give you a thumbs up if you do this problem correctly. Sorting Analysis Code and Essay ...

    Hi i will give you a thumbs up if you do this problem correctly. Sorting Analysis Code and Essay Due: 4/22/2019(Monday) Introduction And now for something completely different.   Different sorting algorithms are better for different size data sets.   Other sorting algorithms are better for data sets of a specific type – for instance, data that is already ordered. In this assignment you will implement four different sorting algorithms and collect statistics for each of those algorithms while sorting multiple different...

  • Using Arrays with Sorting and Searching Algorithms 1) This program has six required outputs and involves...

    Using Arrays with Sorting and Searching Algorithms 1) This program has six required outputs and involves searching and sorting an array of integers. Write a java application that initializes an array with the following numbers, in this order: 23, 17, 5, 90, 12, 44, 38, 84, 77, 3, 66, 55, 1, 19, 37, 88, 8, 97, 25, 50, 75, 61, and 49. Then display the unsorted values. This is required output #1 of 6 for this program. 2) Using a...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT