Ask coding questions

← Back to all posts
Edhesive Assignment 5 help

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?
Enter a number
Enter a number
Enter a number
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?
Not a valid length!

Sample Run 3
How long do you want the array?
Enter a number
Enter a number
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?
Enter a number
Enter a number
Enter a number
Enter a number
Enter a number
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

Here's my code:
Please help me. This assignment is due today.
EDIT: Please help


Instead of pasting the code here, link the repl to the post. Dong so not only makes it readable, but it also lets us see firsthand and easily fork+edit it, so that we can better help you.


@AllAwesome497 Sorry about that. I'm new to this website, so forgive me for not being clear about everything.


@jedifan65 No worries.


Also would be helpful to let us know the assignment as well since trying to piece your assignment together from the code kinda isn't fun


@jeefma Sorry about that. Here's the assignment details: Instructions
For this assignment, you will write a program which creates an array of decimal numbers from a user's input, then returns some simple statistics about the array.

The program should first ask the user how long they wish the array to be (must be a positive integer). If the user enters a non-positive integer then the program should display "Not a valid length!", then stop. Otherwise, the program should create an array of this length, then prompt the user to enter double values one at a time, filling the array from the start with the user's inputs until the array is full.

Once the array is filled the program should print the numbers in the array, followed by the average (arithmetic mean) of the values, the range of the values, and a statement on whether the array is sorted in increasing order, decreasing order or neither.

The average of the values is found by dividing the sum of the numbers by the amount of numbers in the array (note: this may cause roundoff errors, which you do not need to worry about for this assignment).
The range of the numbers is found by subtracting the smallest number in the array from the largest number in the array.
The array is sorted in increasing order if every number is greater than or equal to the previous number. The array is sorted in decreasing order if every element is less than or equal to the previous number. If neither of these is true then the list is unsorted. If every element on the list is the same, then it is counted as being in increasing order.


Clayie is one of the Online Flower Delivery and Home Decor Items stores in India, also one of the leading Plants.


My writing skills are not good. Especially very hard for me to write different essays. But I found a service which helps me with film critique essay
If you need help, you just try it also.


A marketing plan writing service comes in handy for students who do not know how to write a great marketing plan of exceptional quality. As a rule, effective marketing plans belong to the type of business writing that can advertise some products and services or provide some information about them in order to reach the target consumers. More about this


@lindatyler I disagree with you, because writing essays is really a simple task, but only for those who have tried to learn the art of writing them before. In fact, there is nothing difficult to acquire this skill several times a week by watching training videos on YouTube from famous writers who tell you how to write essays on any topic and practice after watching. YouTube is full of such tutorials and they are usually posted on channels with at least 34 thousand subscribers! I'm sure their authors are using to increase their number.


If I were a programmer, I would appreciate your code, but, unfortunately, I do not understand anything about this, as well as about writing) And for this I even turn to professionals for help in this regard.


@nameno10 nice thoughts! Don't you think it's worth posting these thoughts on Instagram? After all, this social network is now very popular. By the way, I advise you use the services of in order to quickly increase the number of subscribers and promote your account to the top.


Our professional assignment writers - are happily provide writing help on assignment, essay and dissertation at Quality Assignment which is leading academic writing help provider company in UK.


By profession I am an assignment writer and happily serve assignment writing help and essay help at Assignment Help Folks - which is leading educational help providers in Australia.


did you ever figure it out? because i am stuck on this part as well :/