Question: ( More practice on the binary operators ) Prof. Lee is taking his friends and family to La Ronde, Montreal s iconic amusement park. The
More practice on the binary operators Prof. Lee is taking his friends and family to La Ronde, Montreals iconic amusement park. The heights of his group of people, measured in centimeters, are recorded in the following vector:
heights c
Prof. Lees group is eager to ride the roller coaster, but theres a catch: only those whose height falls between cm and cm are allowed on the ride. With this heartbreaking news, answer the following questions:
To quickly determine who meets the height requirement, Prof. Lee decides to assign each person a unique English letter. In R the LETTERS vector provides all the capital letters of the alphabet.
LETTERS
ABCDEFGH "I" JKLMNOPQRS
TUVWXYZ
Using LETTERS, find a simple way to assign A to Jin order to each member of the group. So youll have to have the following:
heights
A B C D E F G H I J
NOTE. Refrain from manually assigning characters to the group members onebyone.
Next, we need to determine who is too tall, too short, or appropriately sized for the ride. Using appropriate binary operators, create a new vector named heightseval. This vector should have the same indices as heights, with values assigned according to the following rules:
If the height is less than assign short
If the height is between and inclusive assign pass
If the height is greater than assign tall
The resulting vector should look like this:
heightseval
"short" "tall" "tall" "short" "pass" "pass" "pass" "short" "pass"
"tall"
Hint. You can start creating a vector of length and modify the values later. For example, heightseval rep does the job.
By using the results from part a and b write a code that prints the names whose height is appropriate for the ride. So your code should print the following:
EFG "I"
Instead of riding the roller coaster, Prof. Lees group decided to try a different attraction. Fortunately, everyone can take this ride, but the entrance fee varies based on height:
Heights below cm: CAD
Heights between and cm inclusive: CAD
Heights above cm: CAD
Using your solutions from parts a and b write a code that calculates and prints the total entrance fee Prof. Lees group has to pay.
NOTE. Refrain from manually assigning entrance fee to the group members onebyone.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
