Project #161234 - homework #3

Computer Tutors

Subject Computer
Due By (Pacific Time) 12/19/2016 06:00 pm

Exercises: 1) 18 points: Assume num has a value of 4 and word has a value of “Fun”. Determine whether each of the following complex conditions evaluates to true or false and explain your answer. a) (2 < num) AND (num < 6) b) (2 < num) OR (num < 6) c) (word = “Fun”) OR (word = “fun”) d) ((2 < num) AND (num = 5+1)) OR (word = “fun”) e) ((num = 2) AND (num = 7)) OR (word = “Fun”) f) (num = 2) AND ((num = 7) OR (word = “Fun”)) g) ((2 < num) AND (num < 6)) AND ((word = “Fun”) OR (word = “fun”)) 2) 25 points: Write if statements for each of the following. Possible outcomes are underlined. The if statements must contain the outcomes exactly as written below. a) a little cold if the temperature is less than 60, nice weather otherwise. b) $1 if the number of cents is a 100. c) player wins if player earns at least 20 points, player loses otherwise. d) 10% discount if total amount due is $100-$200 (including 100 and 200). e) free for children 2 and younger or adults 65 and older; $5 otherwise. 3) 25 points: There is a simple card game played with a deck of cards where a player receives four cards and two of those cards have to be same (they have to form a pair) in order to win. The computer has to determine if the player won using just one complex if statement. a) 10 points: Create a systematic list of the possible combinations of cards that could form a pair (for example, Card1 & Card 2 could have the same value and make a pair). Use the table structure below. Card 1 Card 2 Card 3 Card 4 X X b) 15 points: Write an if statement that checks all of the possible combinations of cards that could form a pair in order to determine if a pair exists. Recall that you should be writing only one complex if statement. The outcome would be is a pair or is not a pair. 4) 32 points: For each of the following if statements trace through the test cases given and determine the outcome. The outcome in your answer must be written exactly as it is written within the if statement. a) if (age < 10) AND (age > 50) then receives a discount else does not receive a discount end if age Outcome 80 45 3 50 10 b) if (test1Grade < test2Grade) AND (test1Grade < test3Grade) then test2Grade is not the lowest else test1Grade is not the lowest end if test1Grade test2Grade test3Grade outcome 60 70 80 60 80 70 70 60 80 70 80 60 80 60 70 80 70 60 c) if ((day = "Friday") OR (day = "Saturday")) AND (time = "10pm") then time to go out else stay home end if day time Outcome Monday 10pm Monday 7pm Friday 7pm Saturday 10pm Friday 10am

TutorRating
pallavi

out of 1971 reviews
amosmm

out of 766 reviews
PhyzKyd

out of 1164 reviews
rajdeep77

out of 721 reviews
sctys

out of 1600 reviews
sharadgreen

out of 770 reviews
topnotcher

out of 766 reviews
XXXIAO

out of 680 reviews