# Week 5 Assignments New

**Topics:**Assignment, Relational operator, Equals sign

**Pages:**5 (754 words)

**Published:**February 11, 2015

Unit 5 Assignment 1: Homework

1.) Design an if-then statement that assigns 20 to the variable y and assigns 40 to the variable z if the variable x is greater than 100. (Simple if statement) If x > 100 then

Y=20

Z=40

End if

2.) Design an if-then statement that assigns 0 to the variable b and assigns 1 to the variable c if variable a is less than 10. (Simple if statement)

3.) Design an if-then-else statement that assigns 0 to variable b if variable a is less than 10, otherwise it should assign 99 to variable b. (Alternative if statement) If a < 10 then

B = 0

Else

B = 99

End f

4.) The symbols >,

Unit 5 Labs

1.) Lab 5.1: Evaluating Conditions with Relational Operators.

Critical Review

A relational operator determines whether a specific relationship exists between two values.

Relational operators

Operator

Meaning

Boolean Expression

>

Greater than

X > Y

<

Less than

X < Y

>=

Greater than or equal to

X >= Y

yourAge = 18

myNumber = 81

yourNumber = 17

votingAge = 18

myName = “Katie”

yourName = “Bob

Step 2: Based on the values to the variables in Step 1, do the following conditions result in a true or false statement?

2.) Lab 5.2: Evaluating Outputs Resulting from Relational Condition Evaluations.

Step 3: Based on the values to the variables in Step 1 above, what is the expected output resulting from the conditions below? If no output will be produced, type no output in the expected output column.

The condition

Expected Output

If myName == yourName Then

print “We have the same name”

End If

------

If myAge >= yourAge Then

print “I am older or equal to your age”

End If

If myName != “Katie” Then

print “That is not my name”

End If

If myName == “Katie” Then

print “That is my name”

End If

If myNumber == 17 Then

print “My number is 17”

End If

If myNumber >=80 Then

print “My number is 80 or more”

End If

If yourNumber = votingAge Then

print “You can vote”

End If

If myAge < yourAge Then

print “I am younger”

End If

3.) Lab 5.3: Pseudocode

Store and Employee Bonus Program

Problem:

A retail company assigns a $5000 store bonus if monthly sales are $100,000 or more. Additionally, if their sales exceed 125% (112,500), or more of their monthly goal of $90,000, then all employees will receive a message stating that they will get a day off.

The retail company would like you to build a program for them that would determine if bonuses have been earned, as well as a day off.

Write the pseudocode for your solution to this problem. Use your own words – don’t have to follow the book example.

Inputs

Get monthly sales

Process

Calc store bonus

Monthly sales >= 100,000

Sale bonus = 500

Day off

Monthly sales > 112500

Day off= yes

Out put

Monthly sales

Store bonus

Day off

4.) Lab 5.4: Using Raptor, flowchart your solution to the Store and Employee Bonus outlined above. Note the following:

Your flowchart should have 5 functions – main(), getSales(), determineBonus(sales),...

Please join StudyMode to read the full document