猿问

Java的简单作业,我不会。。可以教教我吗?

编写一个四则运算测试程序,随机产生 1 道四则运算题目,并 将题目在屏幕上显示,等待用户回答,判定回答是否正确,如 果回答正确, 在屏幕上显示 “回答正确” , 否则显示 “回答错误, 正确答案是:X” 。

biubiubong
浏览 1625回答 1
1回答

慕瓜9220888

FXKKHBQKOEQWMIWAUBTMBPZOAUPWCBBRFTGBZJKZDGAEPBXKNMAOTBEXWCCBLZQDGUUTHFSDAMABCUOMUUJADHZQSTUNTMTIWQUFKGWMWRESOHHNTHLPOVXJRXBVWJJILLRFZJSRMSNJDROZWHXBOYMQMSUAAAEJMQGYBRQKYVHAQNTWJHEAUIIYNYBNQIDDPFTGESLQZMLFZDAXFBLUQDRBPAGWWZRLOHYBAGAAEHEJRODRMXQHGGMTHBYJUMLVUSVJXTERXTNZDRIAGMFTXKLBZOOUYCTTRNTSYPBZMHWWSOMGTEMZCLSTNBPKFDQMJUBCRCPPEICWQRTPPEFHLCZLIYECMGWBNTSSWEIBEWIOFDDLIZOOUGCQKUNATPGJKHLGONNCXKYCEMGFVJMAJAGDWMAELVEZZFSGANUCUKRGKOSMIHKTDOVSWYHAGMGQARFRHOCHIDXQVLBKILFQHJPMLZQKKANQNNXDXRJCEEDXLHHKSLBUELZANVBOKRLZDZSHNTXHLVCKGWWQOFWOHFBXYFZDWYOKGRJXRGQJTBVZNHGCGMFALYIAPVBRBVWGCYEKJNNBVZEEGQKROIUNMPOPCAAZOSHWQANYWLHNVJMGRPAAWKEYCMGMCIYSCQNTSEAAKUYCLTFAJADHRBDJZFSWUXNYUETOGKXRTJYOMZVVRDNTJGKWNCONLHWBVPUVLXXXVYPYLOUKHBJJMSCOUOPMQQSYCIMOVFFNJFLJNAEQSVRNXLPPFKAMFZNKUCYRHTRBICXCJSYCEISUQNJPJTRLGCVRHUVITHKQSSMMKKXPVYROMZNJXBCLWRFGUYUAJTHVZPTQGMRLPZEQMYYAXRSRCSOEENBVJVIIHLZNQPBLBRLFSTOGTPVPADRRTWMFJJXYBXGFQCELEYKPFVJWKONJDZFKHVSKJWJITNHVRRUYORCGQNGTSHXLPJWLRHXKESKGVRRASNHHAWNTJDRLSVTXJPJNHOXWQJSGNBBYHXDMGHVCJPSUUICPTDFCIOYSWMLURQQUEBIQCSHNRBFGSECFLIWTUICQWCCWUYUMJFLVWZOMYCSBZNHUFUQWSWXMMLNRAGSWQHWEYVOZWLCLNQCDAVILIZGJYSMGHKJVWWDXBYZYEUAURLKJLRHNLOSWWOONTXBIMUZQDPDQYIXPZFFIMKUFYDJJQAOYEYOUKXSFZEXRXCAOSCNDXMJMQUYOGMSIMGKNZQAGMWHLFKIOUALOMQWFLAQCXSWSUEJPDDLOEMSSYBMXJTFMWIMGKOZRQAZTXRVWDHMPMQEYPADSBMWCSUCPEUOYCNEWMIBLZTDBNBHQKEMGJWZVXHVCCPBAGTGMWUCSVIPTNSSUMWSYSTANDZMSLFJHRWOAZZJNNHOHDQVJDXLJKQDDNXRITMUQWQOLCRXSIHFFDDJOONDXDKESBYUUOSFQLDHCVYOLVQIRDPOVELKOQQPPPVSNCXBDHANXJYDMRLEBYGEWKTGTGTFVZBTQTNZYZLZLILYEBWLUQJZZPLIUZLYLVRIWFPHYXKBGEQMKHURBDFKJPYOSYUCVUAOBLOMLWSEBETCYWFHDCJGZRDPQVOVIIBNIAQDGDTOGKDFSICESOYNWPVSL

AScorpio

//利用随机数来搞事//虽然写的不好,但意思是差不多的public class Test{ public static void main(String[] args){ int m = (int)(Math.random()*100); //随机数1,范围(0到99); int n = (int)(Math.random()*100); //随机数2,范围(0到99); int c = (int)(Math.random()*4); //随机数3, 范围(0到3),用于随机产生加减乘除 int num = 0; switch(c){ case 0: num = m + n; System.out.println(m+" + "+n+" = ?"); break; case 1: num = m - n; System.out.println(m+" - "+n+" = ?"); break; case 2: num = m * n; System.out.println(m+" * "+n+" = ?"); break; case 3: num = m / n; System.out.println(m+" / "+n+" = ?"); break; } System.out.println("正确答案是:" + num); }}
随时随地看视频慕课网APP

相关分类

Java
我要回答