2015/3/6 Introduction to Software engineering classroom operations

Source: Internet
Author: User

Experimental requirements: Write a piece of code, execute the result output 30 arithmetic topic, consider the level of second grade students in primary school

Experiment idea: Use random method to generate the stochastic number, define each number range; Select an operator randomly with switch and edit the output order of the number and symbol

The code is as follows:

Import java.util.*;

public class Test {

public static void Main (string[] args) {

TODO auto-generated Method Stub

for (int i = 0; i <; i++) {

Random r = new Random ();

int a = r.nextint (100);

int b = r.nextint (100);

int c = R.nextint (4);

char d = ';

Switch (c) {

Case 0:

d = ' + ';

Break

Case 1:

d = '-';

Break

Case 2:

d = ' x ';

Break

Case 3:

d = ' ÷ ';

if (b==0) {

i--;

Continue

}

Break

Default

d = ';

}

SYSTEM.OUT.PRINTLN (i + 1 + "." + A + D + b);

}

}

}

2015/3/6 Introduction to Software engineering classroom operations

Related Article

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.