PT1420 - Unit 5 Homework and Lab Assignment
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
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
B = 99
4.) The symbols >,
Unit 5 Labs
1.) Lab 5.1: Evaluating Conditions with Relational Operators.
A relational operator determines whether a specific relationship exists between two values.
X > Y
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.
If myName == yourName Then
print “We have the same name”
If myAge >= yourAge Then
print “I am older or equal to your age”
If myName != “Katie” Then
print “That is not my name”
If myName == “Katie” Then
print “That is my name”
If myNumber == 17 Then
print “My number is 17”
If myNumber >=80 Then
print “My number is 80 or more”
If yourNumber = votingAge Then
print “You can vote”
If myAge < yourAge Then
print “I am younger”
3.) Lab 5.3: Pseudocode
Store and Employee Bonus Program
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.
Get monthly sales
Calc store bonus
Monthly sales >= 100,000
Sale bonus = 500
Monthly sales > 112500
Day off= yes
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