在代码中抛出异常 [英] throw an exception in code

查看:80
本文介绍了在代码中抛出异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经有一段时间了,因为我有Java ...我正在努力写一个程序,它会增加成绩并给予和平均......并且当一个等级低于0或者高于100时抛出异常。 ...任何人都可以在写入方向上旋转我吗?

解决方案


我已经有一段时间了,因为我有Java ..我正在坚持写一个程序,它会增加成绩并给予和平均......当一个低于0的等级被加上或超过100时会抛出一个例外....有人可以在写指示中旋转我吗?



等级是否会通过控制台输入?

到目前为止你有什么?


我不确定..我希望通过一个小小程序添加它们但我不知道该怎么做...所以如果控制台是最简单的方式....我还没有开始实际上把它放在一起...我正在寻找一些方向如何以最干净但最基本的方式解决这个问题



im不确定..我希望他们通过一个小小程序添加,但我不知道该怎么做...所以如果控制台是最简单的方式....我还没有开始实际把它放在一起...我正在寻找一些关于如何以最干净但最基本的方式解决这个问题的方向。



最基本的方法是通过控制台做到这一点。 br />
查看java.util.Scanner类然后尝试一些代码并发布如果你遇到任何问题毫秒。


Its been a while since I have had Java..I am getting stuck tying to write a program that will add up grades and give and average...and throw an exception when a grade below 0 is added or above 100....can anyone spin me in the write directions?

解决方案

Its been a while since I have had Java..I am getting stuck tying to write a program that will add up grades and give and average...and throw an exception when a grade below 0 is added or above 100....can anyone spin me in the write directions?

Are the grades going to be entered through the console?
What do you have so far?


im not sure..i would like them to be added through a small applet but I have no idea how to do that anymore...so if the console is the easiest way ....I have not yet started to actually put this together...i am looking for some direction on how to pull this off in the cleanest yet most basic way


im not sure..i would like them to be added through a small applet but I have no idea how to do that anymore...so if the console is the easiest way ....I have not yet started to actually put this together...i am looking for some direction on how to pull this off in the cleanest yet most basic way

Most basic way is to do that through the console.
Have a look at the java.util.Scanner class then try some code and post if you get any problems.


这篇关于在代码中抛出异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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