The "opposite" of <=
is >
.
Often there are several options that might be included in a major purchase. Each one might be accepted or rejected. Say that you are buying a new car:
You have decided to buy a new sports car. The base price is $20,000. There are two options:
The price of the car is the base price plus the price of the options. Write a program that calculates the price of the car.
Here is an incomplete version. The user is expected to enter "1" to mean true and "0" to mean false. (There are better ways to do this which will be covered in later chapters.)
Notice how the number in totalCost
is accumulated: it is initialized
in its declaration, then added to in each of the true branches.
Fill in the two blanks to complete the program. You may wish to copy the program to a file and try it out.