# Software Engineering--second assignment

Source: Internet
Author: User

First, the topic

Please write a "software" that can automatically generate primary arithmetic topics.
Allow the program to accept the user to enter the answer, and determine the right and wrong.
Finally, the total number of pairs/errors is given.

Second, demand analysis

This program is suitable for elementary school students, exercise their computing ability. Practice the software.

Third, Basic Requirements

1. Display the number of questions

2, automatic display of the topic

3, the user can answer questions

4. Show right and wrong answers

5. Statistics on the number of errors

Iv. implementation of the Code

Import Java.util.Scanner;
public class Calculator {
public static int Suiji (int num1,int num2) {
int c= (int) num1+ (int) (Math.random () * (NUM2-NUM1));
return C;
}
public static void Main (string[] args) {

int s,a,b,i=1,f=0,h=0;
Double D;
while (i<=5) {
S=suiji (1,4);
i=i+1;
A=suiji (0,100);
B=suiji (0,100);
Switch (S) {
Case 1:
System.out.println (A + "+" +b+ "=");
if (d==a+b) {
h++;
}
else{
System.out.println ("The Wrong answer is:" + (a+b));

}
Break
Case 2:
System.out.println (A + "*" +b+ "=");
if (d==a*b) {
h++;
}
else{
System.out.println ("The Wrong answer is:" + (a*b));

}
Break
Case 3:
System.out.println (A + "-" +b+ "=");
if (d==a-b) {
h++;
}
else{
System.out.println ("The Wrong answer is:" + (A-B));

}
Break
Case 4:
System.out.println (A + "/" +b+ "=");
if (d==a/b) {
h++;
}
else{

}
Break
}
Continue
}
SYSTEM.OUT.PRINTLN ("You have correctly answered the" +h+ "question");
}

}

V: Running Result:

Vi. Analysis and summary

Software design is a continuous process, this process needs to have a rigorous concept and careful logical thinking, in the design of the program, the use of their familiar Java language relative to C + + easier, this would like to design a Java Swing GUI program, but due to time constraints, failed to carry out, Later use free time to try to write the program, in order to improve their programming ability!

Vii. PSP Statistics Table

Software Engineering--second assignment

Related Keywords:
Related Article

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.