# CS1411 - 160 - Programming Principles I, Spring 2005

## Motivation

This weeks you will practice variables, typecasts and if-statements

## Mandatory work

Your TA will check that you have done the following things (you may leave once their done) :

### Program 1

Ask the users for two integer numbers (the range should be big enough to enter 1 mio). Store them in variables you call "a" and "b".

Calculate a / b (integer division) and store the result in an integer variable called "i"

Calculate the remainder of a/b (integer division) and store the results in an integer variable called "m" (hint: need modulo operator)

calculate a / b (floating point division) and store the result in a floating point variable called "f" (use static_cast)

Output i, m and f with some explaining text

### Program 2

• Ask the user to input an age (whole number) and store it
• Ask the user to input how much money he has (floating point value) and store it
• If he's at least 21 and has more than \$5.00 output Let's go out!
• If he's under 21, but has more than \$7.00 output Let's go to a movie!
• If none of the above applies output Let's meet at my place

Please note: for "more than \$5.00 / \$7.00" you may use either > or >=

## Optional work

Some other things that you might try:

• For program 1: Output a*b. Change all integer datatypes to short. Try some multiplications that go beyond the range (e.g. 50 * 1000)
• For program 2: Add some more options

## How?

Please check the labs page on how to get started. There are instructions for visual studio (use version 6) and XCode

Please give the Macs a try. If you simply cannot work with them, go to PE 119, but let your TA know.

## Sample programs

have moved to the examples page