如何查找总费用,最低费用和最高费用的平均值,并在消息框中显示。 [英] How to find the average of total charges, minimum charges and maximum charges and display in messagebox.

查看:113
本文介绍了如何查找总费用,最低费用和最高费用的平均值,并在消息框中显示。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

输入3个订单并单击显示统计按钮后,总消费,最低费用和最高费用(存储在totalArray中的总费用)的平均值将显示在消息框中。



i不知道怎么写这个代码,如果有人知道请帮忙。





谢谢。



我的尝试:



i没有尝试任何东西,因为我们的老师没有解释任何事情,并希望我们写下来。我已经在互联网上查看并没有帮助。

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.

推荐答案

添加所有相关值,并在迭代数字列表时检查最小值和最大值。获得总数和值后,就可以计算出平均值。然后根据需要显示每个值。只是简单的数学。
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.


我们不做你的HomeWork。

HomeWork没有设置测试你的技能,乞求其他人做你的工作,它是设置让您思考并帮助您的老师检查您对所学课程的理解以及您应用这些课程时遇到的问题。

你的任何失败都会帮助你的老师发现你的弱点并设定补救措施。

所以,试一试,重读你的课程并开始工作。如果您遇到特定问题,请显示您的代码并解释这个问题,我们可能会提供帮助。



作为程序员,您的工作是创建算法解决特定问题,你不能依赖别人永远为你做,所以有一段时间你必须学会​​如何。而且越快越好。

当你要求解决方案时,就像试图通过培训其他人来学习开车一样。

创建算法基本上是找到数学并做出必要的调整以适应你的实际问题。

--------

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.
--------
引用:

我没有尝试任何事情,因为我们的老师没有解释任何事情,并希望我们写下来。

i haven't tried anything because our teacher hasn't explained anything and expect us to write it.

告诉他,你因为他而失败了。事情的顺序是HomeWork的课程。



Tell him, that you failed because of him. The order of things is lessons then HomeWork.

引用:

我没有想法如何为此编写代码

i have no idea how to write the code for this

如果你不能编写代码,至少你可以做数学。

If you can't write code, at least you can do the maths.


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();





现在只显示平均值。文本框的最小值和最大值。注意:m用于使其成为小数。



Now just display the avg. min and max to textbox. Note: m used is to make it decimal.


这篇关于如何查找总费用,最低费用和最高费用的平均值,并在消息框中显示。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆