6. What is a source program?
A source program is a program written in a high-level language. It’s a program that
creates the rules or syntax of the language
7. What kind of errors are reported by a compiler?
A compiler translates instructions written in java into bytecode. It specifically looks for
syntax errors, and if no errors are found it translates the program.
8. Why do you need to translate a program written in a high-level language into machine
language?
The computer cannot directly execute instructions written in high-level language, so it
has to be translated.
9. Why would you prefer to write a program in a high-level language rather than a machine
language?
Because it is closer to spoken languages and is easier to understand and devise.
11. Design an algorithm to find the weighted average of four test scores. The four test scores
and their respective weights are given in the following format: testscore1 weight1
testscore2 weight2
...
For example, a sample data is as follows:
75 0.20
95 0.35
85 0.15
65 0.30
weightedaverage= (testscore1 x weight1) + (testscore2 x weight2) + (testscore3 x
weight3) + (testscore4 x weight4)
Additional question: What did you learn about computers in Chapter 1 that were new or
surprising to you? Briefly explain.
What surprised me the most in chapter one was the fact that the high-level language
needed to be translated into machine language. I initially believed that the computer read the
high-level language and executed it from there.