3.15.1. Pretest¶
-
Gym Membership Discount
- If the person is 60 years old or older and visits the gym 3 times or more per week, they get a 30% discount.
- If the person is less than 60 years old and visits the gym 5 times or more per week, they get a 15% discount.
- If neither condition is met, and the person is between 18 and 25 years old (inclusive), they get a 5% discount.
- Otherwise, there is no discount.
- 1. A
- 2. B
- 3. C
- 4. D
A gym offers discounts on membership fees based on age and frequency of visits per week. The parameter
age
is the person's age in years, and visitsPerWeek
is the average number of visits per week. The result is the discount percentage encoded as an int. The conditions are:
-
Lucky Number
- If the day is even and the hour is greater than 12, the lucky number is the sum of the day and the hour.
- If the day is even and the hour is less or equal than 12, the lucky number is the product of the day and the hour.
- If the day is odd and the hour is greater than 10, the lucky number is the hour minus the day.
- If the day is odd and the hour is less or equal than 10, the lucky number is the day minus the hour.
- 1. A
- 2. B
- 3. C
- 4. D
An old witch told us a person's lucky number is determined based on the date and time of their birth. The parameters are
day
and hour
. The day
is the day of birth (from 1 to 31), and the hour
is the hour of birth (from 0 to 23). According to her, the lucky number is calculated as follows:
Apartment Cleaning
- You and your roommate are deciding whether to clean the apartment. The parameter
yourMessiness
represents how messy your side of the apartment is, androommateMessiness
represents how messy your roommate’s side is, both in the range from 0 to 20. The result is anint
value indicating whether it’s time to clean. Return: If either messiness is 5 or less (i.e., it’s still relatively clean), return 0 (no need to clean);
With the exception that if either messiness is 18 or more (i.e. the apartment is very messy), return 2 (definitely needs to clean);
Otherwise, return 1 (maybe).
Example Input |
Expected Output |
---|---|
|
|
|
|
|
|
You have attempted of activities on this page