This Graded Project promotes the following learning outcomes:
·
Select and implement appropriate data types, expressions and control structures to solve simple, typical programming problems
Complete the following exercises
1. Given two defined variables: (1 point)
· A float named
totalWeight
that has the weight of a shipment
· An int named
quantity
,
that has the number of items in the shipment.
Write an
instruction
that calculates the weight of
one item and stores it in a variable named
cost4One
.
2. Given that a variable named
average
, has already been calculated, write an
expression
that is True if and only if average is
less
than 60.5. (1 point)
3. Assume: 3 counter variables named
minors, adults
, and
seniors
have been defined with starting value 0 and variable
age
has received valid input from the keyboard. Write an
if/else
statement that adds 1 to
nminors
if age is
less
than 18, adds 1 to
adults
if age is 18 through 64 and adds 1 to
seniors
if age is 65 or older. (2 points)
4. Write a loop that reads positive integers from keyboard input and will stop executing when it reads an integer that is not positive. After the loop ends, it prints out
the sum of all the even integers read. Name your variable whatever you like. (2 points)
5. Write a
for
loop that prints in ascending order all the positive multiples of 5
that are less than
175, each on a separate line. (2 points)