0% found this document useful (0 votes)
28 views

SD234 - Unit 1 - Assn A

You need a compiler to translate high-level code into machine-level code. The code is compiled into binary machine code. Linking combines compiled functions, objects, and classes into a program. Pseudocode was provided to calculate a score from percentages. Feedback was requested to clarify if the exercise required coding in C++ or just conceptual understanding. Keywords are reserved words like int and double while identifiers are user-created variables, functions, etc. Syntax errors in a sample code were identified and corrections were predicted to generate test scores and pay.

Uploaded by

Tim Williams
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views

SD234 - Unit 1 - Assn A

You need a compiler to translate high-level code into machine-level code. The code is compiled into binary machine code. Linking combines compiled functions, objects, and classes into a program. Pseudocode was provided to calculate a score from percentages. Feedback was requested to clarify if the exercise required coding in C++ or just conceptual understanding. Keywords are reserved words like int and double while identifiers are user-created variables, functions, etc. Syntax errors in a sample code were identified and corrections were predicted to generate test scores and pay.

Uploaded by

Tim Williams
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Unit 1 Assignment A

Why do you need to translate a program written in a high-level language into machine
language? (2 points)
You need a compiler. The code needs to be compiled to machine code, which is binary.
Chapter 1 : Exercise 13 - What is linking? (2 points)
A compilation of functions, objects, classes, etc that get compiled with your program.
Links help to modularize your code and keeps things simpler.
Chapter 1: Exercise 15 - Provide the pseudocode that would be associated with your
solution. Write a short paragraph describing how you came up with your answer (2
points)
=START CODE=
.75 * .20 = .15
.95 * .35 = .3325
.85 * .15 = .1275
.65 * .30 = .195
.15 + .3325 + .1275 + .195 = .805, rounded to .80
Score is 80%
=END CODE=
COMMENTS: Im really confused on this exercise. What exactly are you trying to get
us to do? Does it need to be coded into a C++ program, or is this just a though exercise
to get us to see if we understand how to think this through before it goes into a program.
Please let me know if Im doing this wrong.
Chapter 2: Exercise 4 - What is a keyword and what is a user-defined identifier? (2
points)
A user-defined identifier would be a variable, constant, string, function, or label that the
programmer has created to store data or results from the program. A keyword is a
reserved word that can only be used in its defined state, like double, int, const, or float,
which are keywords used for different numbers.
Chapter 2: Exercise 22 - Resolve the syntax errors. Please rewrite the program entirely
with your corrections included. What do you predict will be the output of the corrected
code? Write each program in Visual C++ or your choice for an IDE (this is to be
decided by your instructor) and compile and run them. What was the output? If different
than your predictions, can you explain why? (4 points)

=START CODE=
#include <iostream>
#include <string>
using namespace std;
const long TOP_NUM = 753409;
const PAY_RATE = 18.35;
int main()
{
int testScore, projectScore, first, topNum1, newTemp;
double temp, hoursWorked, payCheck;
hoursWorked = 40;
testScore = 88;
projectScore = 22;
cout << "Test Score: " << testScore << endl;
cout << "Project Score: " << projectScore << endl;
temp = 82;
newTemp = testScore + 2 * projectScore;
first = 2 * TOP_NUM;
topNum1 = TOP_NUM - 919;
cout << "First: " << first << endl;
cout << "Top Number: " << topNum1 << endl;
payCheck = hoursWorked * PAY_RATE;

cout << "Wages = " << payCheck << endl;


return 0;
}
=END CODE=
COMMENTS: Im not sure here, but it appears it may be to generate test score and pay
rate, maybe together. It doesnt spit out anything useful here, even with the added hours
worked. I dunno. Pray tell.
Submit your assignment using the link above (due on Sunday of this unit; 12 points).

You might also like