Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
After entering 3 orders and when the show statistics button is clicked, the average of total charges, minimum charges and maximum charges ( of total charges stored in the totalArray) are displayed in a Messagebox.

i have no idea how to write the code for this, if someone knows please help.


Thank you.

What I have tried:

i haven't tried anything because our teacher hasn't explained anything and expect us to write it. i have looked in the internet and didn't help.
Posted
Updated 21-Nov-16 21:32pm

Add up all the relevant values, and as you iterate over the list of numbers check for minimum and maximum. Once you have the total and the number of values you can calculate the average. Then display each of the values as required. Just simple mathematics.
 
Share this answer
 
We do not do your HomeWork.
HomeWork is not set to test your skills at begging other people to do your work, it is set to make you think and to help your teacher to check your understanding of the courses you have taken and also the problems you have at applying them.
Any failure of you will help your teacher spot your weaknesses and set remedial actions.
So, give it a try, reread your lessons and start working. If you are stuck on a specific problem, show your code and explain this exact problem, we might help.

As programmer, your job is to create algorithms that solve specific problems and you can't rely on someone else to eternally do it for you, so there is a time where you will have to learn how to. And the sooner, the better.
When you just ask for the solution, it is like trying to learn to drive a car by having someone else training.
Creating an algorithm is basically finding the maths and make necessary adaptation to fit your actual problem.
--------
Quote:
i haven't tried anything because our teacher hasn't explained anything and expect us to write it.
Tell him, that you failed because of him. The order of things is lessons then HomeWork.

Quote:
i have no idea how to write the code for this
If you can't write code, at least you can do the maths.
 
Share this answer
 
C#
decimal[] numbers = {2.1m, 2m, 3m, 5m, 3.2m, 1, 10};
       decimal avg = numbers.Take(numbers.Count()).Average();
       decimal min = numbers.Min();
       decimal max = numbers.Max();


Now just display the avg. min and max to textbox. Note: m used is to make it decimal.
 
Share this answer
 
Comments
Richard MacCutchan 22-Nov-16 3:46am    
You do not help people by writing their homework for them. Homework is supposed to help people to think for themselves.
Philippe Mori 22-Nov-16 15:41pm    
But it is probably not the answer is teacher is expecting... Usually, students are expected to mainly used what they should have learn at that point.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900