Presentation is loading. Please wait.

Presentation is loading. Please wait.

Variables.. Part 2 Calculations. Review of yesterday Three types of variables var num:int var average:real var username:string No decimals Might have.

Similar presentations


Presentation on theme: "Variables.. Part 2 Calculations. Review of yesterday Three types of variables var num:int var average:real var username:string No decimals Might have."— Presentation transcript:

1 Variables.. Part 2 Calculations

2 Review of yesterday Three types of variables var num:int var average:real var username:string No decimals Might have decimals Has letters or characters

3 Structure var statements at the top Ask for input Produce output Example: Ask the user for their name and their mark in Math and Science. Print the output.

4 The assignment operator! X := 7 X “is assigned” the value of 7

5 Calculations Example.. Blue Jays tickets cost $91.25 each. Write a program that will ask how many tickets the user would like and will print the total. var numtickets:int var total:real put "How many tickets".. get numtickets total := 91.25 * numtickets put "Your total is $",total

6 Example 2 Ask the user for their name and their mark in Math and Science. Print their average in the two subjects. How many variables do we need? Next page

7 Example 2 Ask the user for their name and their mark in Math and Science. Print their average in the two subjects. Solution: var math, science:int var average:real var nme:string put "Your name please".. get nme put "What is you Math mark".. get math put "Give me your Science mark".. get science average:= (math + science) / 2 put "Your average is ",average,"%"


Download ppt "Variables.. Part 2 Calculations. Review of yesterday Three types of variables var num:int var average:real var username:string No decimals Might have."

Similar presentations


Ads by Google