Ask coding questions

← Back to all posts
Edhesive Assignment 5 help
jedifan65 (4)

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

Here's my code:https://repl.it/@jedifan65/assignment-5-array-statistics
Please help me. This assignment is due today.
EDIT: Please help

Comments
hotnewtop
AllAwesome497 (397)

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.

jedifan65 (4)

@AllAwesome497 Sorry about that. I'm new to this website, so forgive me for not being clear about everything. https://repl.it/@jedifan65/assignment-5-array-statistics

jeefma (8)

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

jedifan65 (4)

@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.

lindatyler (0)

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 https://essaysservice.com/marketing-plan-writing-service.html

JustinHamm (0)

@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 https://soclikes.com/ to increase their number.

nameno10 (0)

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. https://pro-papers.com/write-my-assignment-for-me

AlexJuvion (1)

Our professional assignment writers - http://www.qualityassignment.co.uk/services/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.

IdaWallace (1)

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

ETHANMEADORS (0)

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