1. How is an attribute declared? How is a constant declared? What is the difference betwen a literal and a constant? Can an attribute have the same name as a class?
2. When should I use a literal and when a constant?
3. What is the default or initial value of an attribute?
4. What are the names of the three numeric types in Eiffel? Is there a class for each type? Is there a text file for each type? How can you get a list of the operators defined for each type?
5. Write
down a command to read in
•
an integer
•
a real number
•
a double precision real number
•
a character
6. An input command gets a value from the user, and stores it in a buffer. How do you get the value from the buffer? How many instructions are there to get a value from an input buffer?
7. Describe
the general method for getting a value from the user. Write the declarations
and code needed to read and store
•
two integers
•
two real numbers
•
an integer and a real number
8. Write
down the command to output
•
an integer
•
a real number
•
a double precision real number
•
a character
9. When do you need a prompt? a label?
10. Explain, step by step, how an assignment statement works.
11. What is meant by operator precedence? What is the numeric operator precedence order?
12. Evaluate the following
expressions, showing each step:
•
1 + 2 * 3 / 4.0
•
1 // 2
•
34 // 4.5
•
1 // 2 \\ 3
•
1 \\ 2 * 3 // 4 / 5.0
•
-43 // 4 ^ 2
•
-((12 / 3.0) * (0 // 7) + 2)
17. Write a class X that consists of a single make routine, plus attributes. The specification is:
"You have decided to become a rock concert entrepreneur and want to use your knowledge of computing to help with the accounting. Write a system that calculates your individual profit and the total attendance for a rock concert.
There are three ticket prices, the cheap seats at $10, the standard seats at $20, and the special seats for $100 each. The special ticket holders get to sit in the front row, plus a pair of autographed sunglasses, plus a chance at a backstage pass. You must pay for the rent on the stadium, cost of the band, security and insurance. The security is calculated at 32 cents per person attending. The insurance is 3.6% of the income.
You have two partners in this venture, and must split the profits evenly between all three partners. You must pay 12.5% tax on any profits made from the concert. Show the net (after tax) profit per person, and the total attendance at the concert."