Simple Four Calculator

Source: Internet
Author: User

Job Requirements : To write a 10 or less subtraction arithmetic, the user selects the operation method, the input result, 0 to 10 of the integer randomly generated, and asked to count the total number of questions, and the correct number, the correct rate.

Design ideas: Using the form application, user operation is simple and understandable. Required CONTROLS: Form 1: Two label controls, Label1 for display operators, label2 for = symbols, 6 button controls. The Click event for +-*/, and the start, end event. Three textbook controls, one for user input results, and two for generating random numbers. Form 2: Three label controls, display title, three textbook controls, record total number of questions, correct number of questions, and correct rate. I use the switch statement to judge the operator and execute the subtraction statement.

is Form 1 and form 2

Code implementation: First define count and right, with an initial value of 0. Click Start, a random number 1 to 10 appears, and the start code is as follows

The user then selects the appropriate operator, Label1 displays the operator selected by the user, then calculates, and the user enters the calculated result

4 button buttons, the code for the operator is as follows

Use the switch statement to determine the operator, and then make a judgment calculation, the code is as follows

When the user clicks the end button, TEXTBOOK3 does not allow the user to enter results, jump to form 2 to display the statistics results form 2 of the writing code below the PSP time-consuming: The plan is 12 hours to complete, the actual time spent 9 hours, just beginning four hours due to various reasons the program runs a bug, did not find errors, failures, The second re-write program, plus the time to write a blog spent 5 hours, plus the first time shared 9 hours. Summary: The code is self-thought out, but to run, there are a lot of errors, and classmates in a discussion, find the wrong, finally find and correct, the sentiment is the program of their own mistakes are not easy to find, and classmates in a discussion can quickly found their own mistakes. So cooperation is the best way to learn. Study questions: If the user wants to calculate 1 to 100, only need to change to int N1, N2;n1=ran. Next (1,101); N2=ran. Next (1,101);

Simple Four Calculator

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.