Problem Dice program

Similar documents
Step by Step An Example for each Application

Objective 1: To simulate the rolling of a die 100 times and to build a probability distribution.

Activity 7. Modeling Exponential Decay with a Look at Asymptotes. Objectives. Introduction. Modeling the Experiment: Casting Out Sixes

Quick and simple ClassPad programs for solving problems such as those posed by Project Euler.

Homework Review: 4-17 to 4-22

Math 574 Review Exam #1

Compliments and Disjoint Events

Tutorial 12 Craps Game Application: Introducing Random Number Generation and Enumerations

hp calculators HP 9g Probability Random Numbers Random Numbers Simulation Practice Using Random Numbers for Simulations

C Functions. 5.2 Program Modules in C

CC INTEGRATED II ETOOLS

BBC Micro:Bit. Year 7. Teacher Guide and Planning

ClassPad website: CASIO Education website:

Heads Up! (Continued)

Quick. ClassPad II. Reference Guide. Press these keys for numbers, basic operations, and the most common variables

Java Assignment 3: Loop Practice Ver 3.0 Last Updated: 12/1/2015 8:57 AM

Section 3.1 Shapes of Distributions MDM4U Jensen

Fractals and the Chaos Game

The Math Class. Using various math class methods. Formatting the values.

Decision Support and Intelligent Systems. Monte Carlo Simulation

CAMBRIDGE TECHNOLOGY IN MATHS Year 12 ClassPad user guide

Introduction to Computer Science with MakeCode for Minecraft

EXCODE. Code An App From Scratch

15-110: Principles of Computing, Spring 2018

Dr M Kasim A Jalil. Faculty of Mechanical Engineering UTM (source: Deitel Associates & Pearson)

Chapter 5 C Functions

Random Walks and Defining Functions FEB 9 AND 11, 2015

Previous Lecture: Today s Lecture: Announcements: Nesting if-statements Logical operators short-circuit. Iteration using for

Place Value. Objectives To develop place-value concepts and connect place value in money with place value in base-10 blocks. Assessment Management

University of Massachusetts Amherst, Electrical and Computer Engineering

More About Objects and Methods

6.S189 Homework 2. What to turn in. Exercise 3.1 Defining A Function. Exercise 3.2 Math Module.

The Hong Kong Polytechnic University

Data Handling. Moving from A to A* Calculate the numbers to be surveyed for a stratified sample (A)

CPSC 427: Object-Oriented Programming

The Math Class (Outsource: Math Class Supplement) Random Numbers. Lab 06 Math Class

ELEC6021 Research Methods Matlab Session 2

What s Normal Anyway?

BASIC SIMULATION CONCEPTS

MFA Pilot Instructions

Quick. ClassPad II. Reference Guide. Press these keys for numbers, basic operations, and the most common variables

Single Dimensional Data. How can computation pick best data values? Or, turn math into searching? How is this Multi-Dimensional Data?

Use Arrays and Collections

Building Java Programs

6 th Grade Enriched Math to 7 th Grade Pre-Algebra

Adding a New Class. In this Chapter: T Defining a New Class. T Adding a New Class Attribute to the app Class. T app Class: Attribute Restrictions

Functions in C++ Problem-Solving Procedure With Modular Design C ++ Function Definition: a single

Discrete Mathematics 2 Exam File Spring 2012

Biostatistics & SAS programming. Kevin Zhang

My first six months with. By Damien Bushby of Blackburn High School, Victoria Presented at MAV Dec, 2007

BLOCK STRUCTURE. class block main method block do-while statement block if statement block. if statement block. Block Structure Page 1

Chapter 1 Histograms, Scatterplots, and Graphs of Functions

Java Outline (Upto Exam 2)

Robotics II. Module 2: Application of Data Programming Blocks

CS220/MATH320 Applied Discrete Mathematics Instructor: Marc Pomplun Practice Exam. Sample Solutions

CIS192 Python Programming

Functions and Recursion

The MSU Department of Mathematics "Account Manager" can be used for the following:

Minitab Lab #1 Math 120 Nguyen 1 of 7

COMP 110 Programming Exercise: Simulation of the Game of Craps

OMNITRACKER Demo Version. Quick Installation Guide

3. Probability 51. probability A numerical value between 0 and 1 assigned to an event to indicate how often the event occurs (in the long run).

IT 374 C# and Applications/ IT695 C# Data Structures

USER GUIDE.

Bitwise Operators Objects and Methods

Experiment 1 Yahtzee or Validating the t-table

Introduction to Basic eactivity Manipulations

Chapter Four: Loops II

Functions. Computer System and programming in C Prentice Hall, Inc. All rights reserved.

Modeling RNA/DNA with Matlab - Chemistry Summer 2007

Fun with Fractals and Functions. CHAMP at University of Houston March 2, 2015 Houston, Texas

Is the result of multiplying 2 positive numbers positive or negative? Is the result of multiplying 2 negative numbers positive or negative?

static int min(int a, int b) Returns the smaller of two int values. static double pow(double a,

Functions. Angela Chih-Wei Tang ( 唐之瑋 ) Department of Communication Engineering National Central University JhongLi, Taiwan.

Getting Started Manual. SmartList To Go

Introduction to LabVIEW. Modified Powerpoint file taken from ma/courses/es110/

EET2141 Project 2: Binary Adder Using Xilinx 7.1i Due Friday April 25

SCRATCH MODULE 3: NUMBER CONVERSIONS

Procedures: Algorithms and Abstraction

TI-84 GRAPHING CALCULATOR

SportPesa for Android

Geometry Activity: Segment and Shape Construction. CALCULATORS: Casio: ClassPad 300 Texas Instruments: TI-89, TI-89 Titanium

12 Lead ECG CardioVu Software Installation Guide

Statistics I 2011/2012 Notes about the third Computer Class: Simulation of samples and goodness of fit; Central Limit Theorem; Confidence intervals.

12/22/11. } Rolling a Six-Sided Die. } Fig 6.7: Rolling a Six-Sided Die 6,000,000 Times

Monte Carlo Techniques. Professor Stephen Sekula Guest Lecture PHY 4321/7305 Sep. 3, 2014

Building Java Programs

Student Name and ID Number. MATH 3012, Quiz 3, April 16, 2018, WTT

Midterm CSE 21 Fall 2012

CIS 162 Project 4 Farkle (a dice game)

Teaching Kids to Program. Lesson Plan: Catch the Ball

OBJECTS AND CLASSES. Examples. You and I are instances of the class of objects known as people.

Condition Controlled Loops. Introduction to Programming - Python

Probability and Statistics for Final Year Engineering Students

OneNote May 13, 2015 Tech Talk Odegaard 220 Greg Frick

Programming for Engineers Functions

CS 540: Introduction to Artificial Intelligence

Born in Tulsa in 1914 and passed away in Norman in 2010.

Math Centers for Common Core. Numbers and Operations: Fractions. Created by Jennifer Findley

Q5. What values are stored in the array at the comment in main? Note that the incrementall returns void, but does take an int[] parameter.

Transcription:

Activity 1 Problem Dice program Aim: Based on the Maths 00 activity Problem Dice, Introduce the Program app to simulate 100 rolls of the dice. Creating a program automates a sequence of instructions we used in the previous activity. The following program takes the commands you used in the previous activity to randomly generate 100 rolls on a pair of dice and draw a histogram of the differences. Enter, save and run a program to simulate the differences game. Program app Open program app Create a new program Tap E Enter a name for the program Maximum of 8 characters Tap OK Enter the program Enter the text as shown Some of the text can be entered from menu [Misc Statistics(1) StatGraph] [Misc Statistics(1) Graph ] [I/O Draw ] randlist(100,1,6) a Simulate 100 rolls of a six-sided die and store as a abs(a b) list1 stores the difference between a and b in list1 StatGraph 1,On,,list1,1 Sets StatGraph 1 to On and to draw a using list1 draws the Run the program Tap { to save the program Tap ) to leave the program editor Tap } to run the program Hazeldene publishing 017 Year 9 Mathematics: ClassPad Activities

Do more: Create frequency table Tap P to edit the program Make the adjustments Modify the program to simulate 00 rolls. Record the frequency and draw the histogram. table 00 rolls Difference 0 1 Modify your program to simulate the sum of 00 rolls of a pair of 8-sided dice and record your results. table Difference 0 1 6 7 Hazeldene publishing 017 Year 9 Mathematics: ClassPad Activities

Modify your program to simulate the sum of 00 rolls of a pair of 6-sided dice and record your results. table Sum 0 1 Modify your program to simulate the sum of 00 rolls of three 6-sided dice and record your results. Be patient! table Sum 6 7 8 9 10 11 1 Hazeldene publishing 017 Year 9 Mathematics: ClassPad Activities

Learning notes Detailed instructions: View this video demo of process of creating the program https://www.youtube.com/watch?v=6bceirazei Learning to program: Many people learn coding by modifying work others have done. You will learn more by taking these programs and then modifying than you will starting from scratch. There is a.vcp file on the website that you can download and access the programs using ClassPad Manager on your laptop. The program explained randlist(100,1,6) a randlist(100,1,6) b abs(a-b) list1 StatGraph 1,On,,list1,1 {0,1,,,,} list {0,0,0,0,0,0} list For 1 i To 100 list1[i]+1 d list[d]+1 list[d] DispListEditor Generate lists of 100 random numbers between 1 and 6 and store Calculate the difference between the two dice and store in list1 Set up the Statistics graph: Statgrpah1, set to a using list1 with a frequency of 1 Draw the graph Initialise lists and. List is the differences and list will store how many results have the matching difference This is a loop to go through the 100 rolls. Note the difference between the dice and save as d. Increment the count for that difference. The + 1 is because the differences started at 0 in the first element in the list. Display the Statistics window showing the frequency table Dice Difference Program modified to run with parameters Specify the number of rolls and the number of faces (max 1) on each die each time you run the program. Statistics app only displays 00 elements in a list. This program allows more trials, but on your handheld expect to be waiting a while! Code as shown in screenshot randlist(n,1,faces) a randlist(n,1,faces) b abs(a-b) list {0,1,,,,,6,7,8,9,10,11} list {0,0,0,0,0,0,0,0,0,0,0,0} list For 1 i To n list[i]+1 d list[d]+1 list[d] Hazeldene publishing 017 Year 9 Mathematics: ClassPad Activities

DispListEditor StatGraph 1,On,,list,list Running from main screen Another coding examples Select from a list without replacement The code works by inputting a list and the number of elements you want o select from that list. The code uses parameters and can be called by another program or in the Main screen. E.g. selectn({1,,,,8,1},) will select two elements and they are stored in variable pick. mylist wklist dim(wklist) l 'initialise list to hold selection seq(0,x,1,n,1) pick For 1 i To n 'Select element rand(1,l) p wklist[p] pick[i] 'Delete selected item from list For p+1 j To l wklist[j] wklist[j-1] 'sublist(wklist,1,p-1)+sublist(wklist,p+1,l) wklist Print pick l-1 l Print mylist Print pick Once it is working the Print statements can be deleted. Hazeldene publishing 017 Year 9 Mathematics: ClassPad Activities 6

Example of running program in Main screen Drawing cards Working in Main Draw a card form a regular deck of cards {,,, } suits {1,,,,,6,7,8,9,10,J,Q,K} kind {0,0} s rand(1,) c suits[mod(c,)+1] s[1] kind[mod(c,1)+1] s[] s The symbols for the card suits Writing a program to simulate dealing a random hand of cards {,,, } suits {1,,,,,6,7,8,9,10,J,Q,K} kind seq(x,x,1,,1) pack selectn(pack,) Pause ClrText For 1 i To Locate,1*i,suits[mod(pack[i],)+1] Locate 1,1*i,kind[mod(pack[i],1)+1] Code of first two versions of dice differences program DiceDiff randlist(100,1,6) a randlist(100,1,6) b abs(a-b) list1 StatGraph 1,On,,list1,1 DiceDif randlist(100,1,6) a randlist(100,1,6) b abs(a-b) list1 StatGraph 1,On,,list1,1 {0,1,,,,} list {0,0,0,0,0,0} list For 1 i To 100 list1[i]+1 d list[d]+1 list[d] DispListEditor Hazeldene publishing 017 Year 9 Mathematics: ClassPad Activities 7