You are on page 1of 10

Le 1

SON C. LE

COSC1415 – 8501 | FALL 2010

INSTRUCTOR: CHARLES HALSEY

CHAPTER 1 ASSIGNMENTS

DUE DATE: 09/01/2010

1. Mark the following statements as true or false:


Le 2

a. The first device known to carry out calculations was the Pascaline -

b. Modern-day computers can accept spoken-word instructions but

cannot imitate human reasoning - F

c. In ASCII coding, every character is coded as a sequence of 8 bits - F

d. A compiler translates a high-level program into assembly language -

e. The arithmetic operations are performed inside CPU, and if an error

is found, it outputs the logical errors. - T

f. A sequence of 0s and 1s is called a decimal code. - F

g. A linker links and loads the object code from main memory into the

CPU for execution. - F

h. Development of a C++ program includes six steps. - T

i. A program written in a high-level programming language is called a

source program. - T

j. ZB stands for zero byte. - F

k. The first step in the problem-solving process is to analyze the

problem. - T
Le 3

l. In object-oriented design, a program is a collection of interacting

functions. - T

2. Two input devices: mouse and keyboard.

3. Two output devices: screen and printer.

4. The secondary storage is needed because the programs and data

stored in main memory will be lost when the computer is turned off, so

these programs must be transferred to other devices for permanent

storage.

5. The operating system monitors the overall activity of the computer and

provides services.

6. There are two types of programs: system programs and

application programs.

7. Machine languages are digital signals which are processed inside a

computer, also called the language of a computer, and consist of a

sequence of 0s and 1s.

High-level languages are languages that are close to natural languages

such as English, French, German, and Spanish.

8. A source program is a program that is written in a high-level language.

9. A compiler is necessary because it translates a program written in

high-level language into machine code, called object code.


Le 4

10. A compiler reports syntax errors.

11. We need to translate a program written in high-level language

into machine language because the computer cannot directly execute

instructions written in a high-level language.

12. I would prefer to write a program in a high-level language because it’s

much easier to understand and is self-explanatory to a novice user

who is familiar with basic arithmetic.

13. Linking is combining the object program with other programs in

the library, and is used in the program to create the executable code.

14. The advantages of problem analysis and algorithm design

directly writing a program in a high level language: it’s a step-by-step

problem-solving process so we can follow and modify it easier; the

problem will be analyzed carefully and understood thoroughly; it’s

much easier to discover errors.

15. Design an algorithm to find the weighted average of four test

scores.

a. Get the first score testscore1

b. Get the second score testscore2

c. Get the third score testscore3

d. Get the fourth score testscore4


Le 5

e. Get the weight of the first score weight1

f. Get the weight of the second score weight2

g. Get the weight of the third score weight3

h. Get the weight of the fourth score weight4

i. Use this formula to determine the average score:

Average score = ((testscore1 * weight1) +

(testscore2*weight2) + (testscore3*weight3) +

(testscore4*weight4))/4

16. Design an algorithm to convert the change given in quarters,

dimes, nickels, and pennies into pennies.

a. Get the amount of quarters given quarters

b. Get the amount of dimes given dimes

c. Get the amount of nickels given nickels

d. Get the amount of pennies given pennies

e. Convert the quarters, dimes, nickels and pennies given into

pennies using this formula:

Result = quarters*25 + dimes*10 + nickels*5 + pennies


Le 6

17. Design an algorithm to find the price of the pizza per square

inch:

a. Get the radius of the pizza

b. Get the price of the pizza

c. Calculate the price of the pizza per square inch using this formula:

Result = price / (3.14*radius*radius)

18. Gasoline algorithm

a. Get the starting odometer startodometer

b. Get the ending odometer endodometer

c. Get the amount of gas put in the car on the first day: Monday

d. Get the amount of gas put in the car on the second day: Tuesday

e. Get the amount of gas put in the car on the third day: Wednesday

f. Get the amount of gas put in the car on the fourth day: Thursday

g. Get the amount of gas put in the car on the fifth day: Friday

h. Calculate the distance the salesperson has traveled from Monday

to Friday using this formula:

distance = endodometer / startodometer


Le 7

i. Calculate the total gasoline totalgas that was put in the car using

this formula:

totalgas = Monday + Tuesday + Wednesday + Thursday +

Thursday + Friday

j. Calculate the average miles per gallon using this formula:

result = distance / totalgas

19. Selling price of an item at the furniture store

Get the original price of the item: origprice

Calculate the selling price sellprice of the item using this formula:

sellprice = 1.6*origprice

20. Triangle area

a. Get the first side a of the triangle

b. Get the second side b of the triangle

c. Get the third side c of the triangle

d. Get the half perimeter s of the triangle using this formula:

s = (a + b + c)/2

e. Calculate the area area of the triangle using this formula:


Le 8

area = sqrt(s(s-a)(s-b)(s-v))

21. Fax algorithm:

a. Get the number of the pages needed to be faxed: page

b. Calculate the amount due using this formula:

If (page <= 10) then amountdue = 3.00 + .20*page

otherwise

amountdue = 5.00 + (page – 10)*.10

22. ATM algorithm

a. Get the amount of money the user wants to withdraw: amount

If (balance <= 0)

*Notice: You are not able to withdraw.

otherwise

If (amount > 500) then

*Notice: The maximum withdrawal is $500.00

Otherwise

If (amount > balance) then servicecharge = $25.00 and

dispense the amount of money

otherwise
Le 9

If (amount > 300) then servicecharge = 0.04*amount and

dispense the amount of money

otherwise

Dispense the amount of money without any service charges

23. Student and Test scores algorithm

a. Get the total number of students: total

b. Get the names of the students: names

c. Get the test scores of the students: testscores

d. Get the sum of the test scores: sum

e. The average test score is determined by the following formula:

Average = sum / total

f. If (testscore < average) then show the name associated with the

testscore

Otherwise

Do not show the name

g. If (ranking of testscore is the highest) then show the name of this

student. Suppose highest stands for the highest test score.


Le 10

h. If (testscore = highest) then show the name associated with the

testscore

You might also like