197k views
5 votes
How to do assignment 5 on edhesive? Please answer​

1 Answer

4 votes

Answer:So my code manages to run every sample run correctly except for sample run 4 which has it as a decreasing array instead of an unsorted array:

Sample Run 1

How long do you want the array?

3

Enter a number

1.3

Enter a number

1.5

Enter a number

8.1

Your array is {1.3, 1.5, 8.1}

The average is 3.633333333333333

The range is 6.8

The array is sorted in increasing order

Sample Run 2

How long do you want the array?

-3

Not a valid length!

Sample Run 3

How long do you want the array?

2

Enter a number

3.6

Enter a number

0.8

Your array is {3.6, 0.8}

The average is 2.2

The range is 2.8

The array is sorted in decreasing order

Sample Run 4

How long do you want the array?

5

Enter a number

2.0

Enter a number

4.1

Enter a number

6.4

Enter a number

0.2

Enter a number

1.3

Your array is {2.0, 4.1, 6.4, 0.2, 1.3}

The average is 2.8

The range is 6.2

The array is unsorted

Step-by-step explanation:

User Karol S
by
4.5k points