COSC175 Selection Homework
Type in Word. Work with a
partner and submit one copy per pair.
Partner 1: Name
Partner 2: Name
For 1 through 11, create an expression using the relational
operators, the logical operators, and variable names of your own choosing, no
if or variable declaration is necessary.
- is a person's age equal to 30?
- is a body temperature greater than 98.6?
- is a person's height less than 6 feet?
- is the current month 12?
- check if the letter input is m
- is a person's age equal to 30 and is the person taller
than 6 feet?
- check if a length is greater than 2 feet and less than 3 feet
- taxRate is over 25% and income is less than $20000
- temperature is less than or equal to 75 or humidity is
less than 70%
- age is over 21 and age is less than 60
- age is 21 or 22
- For what value(s) of x would this condition be true?
(x < 1) && (x > 10)
- For what value(s) of y would this condition be true?
(y >= 1) && (y <= 10)
Write appropriate if statements for each of the following
- If an angle is equal to 90 degrees, print the message
"The angle is a right angle" else print the message "the angle is not a right
- If the temperature is above 100 degrees (celsius), display the
message "above the boiling point of water," else display the message "below
the boiling point of water."
- If the number is positive, add the number to a variable
otherwise add the number to negSum.
- If the slope is less than .5, set a variable named flag to
zero, else set flag to one.
- Write a program to input an integer number. The program should
then output the number and a message saying whether the number is positive,
negative, or zero.
- Write a program to input three numbers and print out the
- Write the statements to input a water temperature (in
Fahrenheit) and print out the state of the water – freezing, boiling, liquid
Write the code and trace for the following:
Design an algorithm that will receive two integers items and display to the
screen their sum, difference, product, and quotient. Do not allow divide by zero
Design an algorithm that will read two numbers and an integer code from the
screen (print a menu of the choices first). If the code is 1, compute the sum of the two numbers. If the code is 2,
compute the difference of the first number minus the second. If the code is 3,
compute the product. If the code is 4 and the second number is not 0, compute
the quotient (divide the first number by the second). If the code is not 1,2,3,
or 4, display an error message. Finally, display the two numbers, the code, and
the result (echo the input).