如何在java中创建一个显示平均50个数字的程序? [英] How to make a program in java that shows the average of 50 numbers ?

查看:141
本文介绍了如何在java中创建一个显示平均50个数字的程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿伙计们!



我的学校有一个编程课,我的老师把这个问题交给我们来解决,就是用Java编写一个程序来显示平均50个数字但它只能显示奇数。



请帮忙!



PS:我是编程的初学者



我尝试了什么:



尝试使用While,If和Else,但我不喜欢知道怎么做!

解决方案

我们不做你的作业:这是有原因的。它就是为了让你思考你被告知的事情,并试着理解它。它也在那里,以便您的导师可以识别您身体虚弱的区域,并将更多的注意力集中在补救措施上。



亲自尝试,你可能会发现它不是和你想的一样困难!



如果遇到具体问题,请询问相关问题,我们会尽力提供帮助。但我们不打算为你做这一切!



首先考虑如何获取数字 - 我们不知道它们来自何处,但我很确定我不想每次手工输入50个数字 - 而仅显示奇数位意味着什么,我们也不知道,但你的家庭作业问题可能更多明确的。

当你有数字时,其余的都是微不足道的:平均=数字之和/数字数。

所以如果你有3个数字:10,20 ,60然后总和是10 + 20 + 60 = 90,计数是3,所以平均值是90/3 = 30.

所有你需要做的就是显示结果用户。


我们不做你的HomeWork。

HomeWork不会测试你乞求别人做你的工作的技巧,它会帮助你您的老师会检查您对所学课程的理解以及您应用这些课程时遇到的问题。

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

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



建议:记一张纸并试着去做手动,你的程序应该使用相同的程序。


Hey guys!

I have a programming class in my school and my teacher put this problem for us to solve, which is to make a program in Java to show the average of 50 numbers but it can only show odd numbers.

Please help!

P.S: I'm a beginner in programming

What I have tried:

Tried with While, If and Else, but i don't know what to do!

解决方案

We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think!

If you meet a specific problem, then please ask about that and we will do our best to help. But we aren't going to do it all for you!

Start by thinking about how to get the numbers - we don't know where they are to come from, but I'm pretty sure I wouldn't want to type in 50 numbers by hand each time - and what the "show only odd numbers" bit means, which we don't know either but your homework question is probably a lot more explicit about.
When you have the numbers, the rest is trivial: average = sum of numbers / count of numbers.
So if you have 3 numbers: 10, 20, 60 then the sum is 10 + 20 + 60 = 90, and the count is three, so the average is 90 / 3 = 30.
All you have to do then is show that result to the user.


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

Advice: tale a sheet of paper and try to do it by hand, your program should use the same procedure.


这篇关于如何在java中创建一个显示平均50个数字的程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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