Software Engineering Personal Assignment 01

Source: Internet
Author: User

Job Requirements:

0 spend 20 minutes writing a "software" that can automatically generate 30 primary arithmetic topics, in addition to integers, to support the arithmetic of true scores.

0 and the students compare the functions of the respective programs, the similarities and differences between the implementation methods and so on. Design ideas: The first automatic generation must have a random number, and then the operator can be randomly used 0~3 instead, in order to represent subtraction, support true score can use an if statement, let the user automatically choose whether the topic is an integer or true score, of which 30 questions let me change to be able to choose the number of topics, This allows you to choose the number of fractional and integer questions, which is easy to use. Source:
Importjava.util.*;//Reference Util Package Public classYunsuan { Public Static voidMain (string[] args) {//TODO auto-generated Method StubRandom ran =NewRandom ();//Initialize random number        intNUM1; intnum2; intnum3; intnum4; intchars; intNUM0;  while(true) {System.out.println ("Enter the number of topics:"); Scanner SCA=NewScanner (system.in); NUM0= Sca.nextint ();//Enter Number of questionsSystem.out.println ("True fractional operation (1), integer operation (0):"); intJudge =Sca.nextint (); if(Judge = = 0)                 for(inti=0; i<num0; i++)                {                    intK = i+1; NUM1= Ran.nextint (100); Num2= Ran.nextint (100); Chars= Ran.nextint (4); if(chars = = 0) System.out.println ("[" +k+ "]" +num1+ "+" +num2+ "="); if(Chars = = 1) System.out.println ("[" +k+ "]" +num1+ "-" +num2+ "="); if(Chars = = 2) System.out.println ("[" +k+ "]" +num1+ "*" +num2+ "="); if(Chars = = 3)                        if(num2 = = 0) I=i-1; ElseSystem.out.println ("[" +k+ "]" +num1+ "/" +num2+ "="); }            Else if(Judge = = 1)                 for(inti=0; i<num0; i++)                {                    intK = i+1; intT; NUM1= Ran.nextint (100); Num2= Ran.nextint (100); NUM3= Ran.nextint (100); NUM4= Ran.nextint (100); Chars= Ran.nextint (4); if(num1>num2) {T=num2; Num2=NUM1; NUM1=T; }                    if(NUM1 = =num2) num2= Num2+1; if(num3>num4) {T=num4; NUM4=num3; NUM3=T; }                    if(num3 = =num4) num4= Num4+1; if(chars = = 0) System.out.println ("[" +k+ "]" +num1+ "/" +num2+ "+" +num3+ "/" +num4+ "="); if(Chars = = 1) System.out.println ("[" +k+ "]" +num1+ "/" +num2+ "-" +num3+ "/" +num4+ "="); if(Chars = = 2) System.out.println ("[" +k+ "] (" +num1+ "/" +num2+ ") * (" +num3+ "/" +num4+ ") ="); if(Chars = = 3) System.out.println ("[" +k+ "] (" +num1+ "/" +num2+ ")/(" +num3+ "/" +num4+ ") ="); }            ElseSystem.out.println ("Wrong input, please try again"); }    }}
arithmetic

Results:

Software Engineering Personal Assignment 01

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.