Timed Math Quiz. In This Part, You Learn How to Generate random numbers by using the Random class. Trigger events to occur at a specific time by using.

Slides:



Advertisements
Similar presentations
Intermediate Formulas & Functions Instructor: Rachel Baltus.
Advertisements

 2007 Dr. Natheer Khasawneh. Chapter 13. Graphical User Interface Concepts: Part 1.
Copyright © 2012 Pearson Education, Inc. Chapter 2 Introduction to Visual C#
Microsoft Visual Basic 2012 CHAPTER TEN Incorporating Databases with ADO.NET.
Microsoft Visual Basic 2010: Reloaded Fourth Edition
Solving Equations by Adding and Subtracting: Vocabulary Solve: To solve an equation mean to find a solution to the equation. Isolate the variable: Get.
ADDING, SUBTRACTING, MULTIPLYING AND DIVIDING INTEGERS By : Katie Kurth and Kateylnn Everhart.
Controls General Discussion. VB Controls Visual Basic Controls A control is the generic name for any object placed on a form Controls may be images,
Slide 1 Chapter 2 Visual Basic Interface. Slide 2 Chapter 2 Windows GUI  A GUI is a graphical user interface.  The interface is what appears on the.
Visual Basic Chapter 1 Mr. Wangler.
Excel Tutorial Enfield High School 2007.
© 2006 Lawrenceville Press Slide 1 Chapter 3 Visual Basic Interface.
Excel Worksheet # 5 Class Agenda Formulas & Functions
Clearly Visual Basic: Programming with Visual Basic 2008
Review for Mid-term! October 26, Review Homework Worksheet True or False Operators are symbols that perform specific operations in Visual Basic.
Dr Dat Tran - Week 1 Lecture Notes 1 Windows Forms Programming Graphical User Interfaces PG (7110) University of Canberra School of Information Sciences.
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 2 Creating a User Interface.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 7 Using Menus, Common Dialogs, Procedures, Functions, and Arrays.
Chapter 9 - VB.Net by Schneider1 Chapter 9 – Additional Controls and Objects 9.1 List Boxes, Combo Boxes, and the File-Opening Control The List Box Control.
 Application – another name for a program.  Interface – is what appears on the screen when the application is running.  Program Code – is instructions.
Representing Data: Constants and Variables CHAPTER THREE Matakuliah: T0063 – Pemrograman Visual Tahun: 2009.
Microsoft Visual Basic 2005 CHAPTER 4 Variables and Arithmetic Operations.
Chapter One An Introduction to Visual Basic 2010 Programming with Microsoft Visual Basic th Edition.
The PictureBox Control Prefix Prefix – pic Image Property PictureBox Image Property – Changes the image or file that appears inside of the PictureBox SizeMode.
CSCI 3327 Visual Basic Chapter 4: Control Statements in Visual Basic (Part 1B) UTPA – Fall 2011.
Adding and Subtracting Rational Numbers 2-2 Objective: Students will add and subtract integers and rational numbers. S. Calahan 2008.
© 2008 The McGraw-Hill Companies, Inc. All rights reserved. WORD 2007 M I C R O S O F T ® THE PROFESSIONAL APPROACH S E R I E S Lesson 15 Advanced Tables.
Joe Hummel, PhD Dept of Mathematics and Computer Science Lake Forest College
Microsoft Access 2010 Chapter 8 Advanced Form Techniques.
Class 3 Remote Instruction Computer Math EDU 556 Programming for Instruction Dr. Steve Broskoske This is an audio PowerCast. Make sure your volume is.
1 Creating Windows GUIs with Visual Studio. 2 Creating the Project New Project Visual C++ Projects Windows Forms Application Give the Project a Name and.
Warm Up Solve. 1. 2x + 9x – 3x + 8 = –4 = 6x + 22 – 4x x = 1
To enter data, place the cursor in the cell. Use Tab to move to the right, Shift-Tab to move back to the left, Enter or Arrow Down to go vertical. You.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 3 Building an Application in the Visual Basic.NET Environment.
Addison Wesley is an imprint of © 2011 Pearson Addison-Wesley. All rights reserved. Chapter 2 Creating Applications with Visual Basic.
Microsoft Visual Basic 2012 CHAPTER FOUR Variables and Arithmetic Operations.
More Visual Basic!. Creating a Standalone Program A standalone program will allow you to make a program file that can be run like other Windows programs,
Ch 3.1 Add and Subtract Signed Numbers Vocabulary Op posites :2 numbers the same distance from 0 but in opposite directions
1 Working with Controls at Run Time. 2 Objectives You will be able to Add controls to a Windows form at run time. Modify controls at run time.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 6 Looping and Multiple Forms.
Chapter 6 Controlling Program Flow with Looping Structures.
Input, Output and Variables GCSE Computer Science – Python.
Microsoft Visual Basic 2010 CHAPTER FOUR Variables and Arithmetic Operations.
Chapter 1: An Introduction to Visual Basic .NET
VISUAL BASIC 6.0 Designed by Mrinal Kanti Nath.
Visual Basic.NET Windows Programming
Microsoft Visual Basic 2005: Reloaded Second Edition
2.5 Another Java Application: Adding Integers
Negative Numbers.
Variables and Arithmetic Operations
Incorporating Databases with ADO.NET
Chapter Eleven Handling Events.
Chapter 1: An Introduction to Visual Basic 2015
Windows Desktop Applications
Chapter 2 Visual Basic Interface
Incorporating Databases with ADO.NET
Chapter 7 Advanced Form Techniques
CHAPTER FIVE Decision Structures.
Variables and Arithmetic Operations
Creating Applications with Visual Basic
Chapter 9 – Additional Controls and Objects
Algebra Stop Being Scared!!!.
Microsoft Visual Basic 2005 BASICS
1 2 3 Animated countdown timer on textured background (Difficult)
Working with Formulas and Functions
Understanding Buttons and TextBoxes
The Step Parameter & Nested For … To … Next loops
Tutorial 10 Automating Tasks with Macros
26 days to go Animated countdown timer on textured background
Presentation transcript:

Timed Math Quiz

In This Part, You Learn How to Generate random numbers by using the Random class. Trigger events to occur at a specific time by using a Timer control. Control program flow by using if else statements. Perform basic arithmetic operations in code.

To create a project and and set properties for a form Create new Project:: MathQuiz || Text Math Quiz. Change the size of the form to 500 pixels wide by 400 pixels tall. Change the value of the FormBorderStyle property to Fixed3D, and set the MaximizeBox property to False. These values prevent quiz takers from resizing the form.

To create the Time Remaining box Add a Label and set (Name) property to timeLabel. Change the AutoSize property to False. Change the BorderStyle property to FixedSingle. Set the Size property to 200, 30. Move the label to the upper-right corner of the form, where blue spacer lines will appear.

Clear Text property Change the value of the Size property to Add Label, and then set its font size to Set the Text property to Time Left.

To add controls for the addition problems Add a Label – Text -> ? – AutoSize->False. – Size->60, 50. – font size->18. – TextAlign->MiddleCenter. – Location->50, 75 – (Name)->plusLeftLabel.

Copy plusLeftLabel label and Paste the label 3 times. Arrange the three new labels so that they are in a row to the right of the plusLeftLabel label. Set the value of the second label's Text property to + (plus sign). Set the value of the third label's (Name) property to plusRightLabel. Set the value of the fourth label's Text property to = (equal sign).

Add a NumericUpDown control – font size to 18, and set its width to 100. – (Name) ->sum.

To add controls for the subtraction, multiplication, and division problems Copy all five controls and then paste them. Change the value of the Text property for the second label to –. Name the first question-mark label minusLeftLabel. Name the second question-mark label minusRightLabel. Name the NumericUpDown control difference.

Paste the five controls two more times. For the third row, name the first label timesLeftLabel, change the second label's Text property to × (multiplication sign), name the third label timesRightLabel, and name the NumericUpDown control product. For the fourth row, name the first label dividedLeftLabel, change the second label's Text property to ÷ (division sign), name the third label dividedRightLabel, and name the NumericUpDown control quotient.

To add a start button and set the tab- index order Add a Button – (Name)-> startButton. – Text-> Start the quiz. – Font->14. – AutoSize->True – TabIndex->1. Set TabIndex – sum->2, difference->3, product->4, and quotient ->5.

To create a random addition problem Add a Random object to your form and named the object randomizer. public partial class Form1 : Form { // Create a Random object called randomizer // to generate random numbers. Random randomizer = new Random();

Add two integer variables to the form, and name them addend1 and addend2. // Create a Random object called randomizer // to generate random numbers. Random randomizer = new Random(); // These integer variables store the numbers // for the addition problem. int addend1; int addend2;

Add a method that's named StartTheQuiz() and that uses the Random object's Next() method to show the random numbers in the labels. StartTheQuiz() will eventually fill in all of the problems and then start the timer.

public void StartTheQuiz() { addend1 = randomizer.Next(51); addend2 = randomizer.Next(51); plusLeftLabel.Text = addend1.ToString(); plusRightLabel.Text = addend2.ToString(); sum.Value = 0; }

Double-click the Start button private void startButton_Click(object sender, EventArgs e) { StartTheQuiz(); startButton.Enabled = false; }

To add a countdown timer Add an integer variable that's named timeLeft public partial class Form1 : Form { randomizer = new Random(); int addend1; int addend2; int timeLeft;

Add Timer Choose the timer1 icon that you just added, and set its Interval property to On the form, double-click the Timer control, or choose it and then choose the Enter key.

private void timer1_Tick(object sender, EventArgs e) { if (timeLeft > 0) { label. timeLeft = timeLeft - 1; timeLabel.Text = timeLeft + " seconds"; } else { // If the user ran out of time, stop the timer, show // a MessageBox, and fill in the answers. timer1.Stop(); timeLabel.Text = "Time's up!"; MessageBox.Show("You didn't finish in time.", "Sorry!"); sum.Value = addend1 + addend2; startButton.Enabled = true; } }

Add three lines to the end of the StartTheQuiz() method timeLeft = 30; timeLabel.Text = "30 seconds"; timer1.Start();

Add the CheckTheAnswer() method. private bool CheckTheAnswer() { if (addend1 + addend2 == sum.Value) return true; else return false; }

To add an Enter event handler for a NumericUpDown control Choose the first NumericUpDown control (named "sum"), and then, in the Properties dialog box, choose the Events icon on the toolbar. Choose the Enter event, enter answer_Enter, and then choose the Enter key.

private void answer_Enter(object sender, EventArgs e) { // Select the whole answer in the NumericUpDown control. NumericUpDown answerBox = sender as NumericUpDown; if (answerBox != null) { int lengthOfAnswer = answerBox.Value.ToString().Length; answerBox.Select(0, lengthOfAnswer); }

Your task Add code of multiplication and dividion