1 Solutions To Assigned Problems
1 Solutions To Assigned Problems
Solutions 1-1
compiler
syntax
logic
hardware
software
Answer:
1.
2.
3.
4.
5.
d.
e.
b.
c.
a.
hardware
software
syntax
logic
compiler
5.
3.
4.
1.
2.
Language translator
Language rules
Order of instructions
Computer system equipment
Another word for programs
a.
b.
c.
d.
e.
compiler
syntax
logic
hardware
software
Input
Processing
Output
B.
A.
B.
4.
5.
Decision
Terminal
Solutions 1-2
D.
C.
4. Draw a flowchart or write pseudocode to represent the logic of a program that allows
the user to enter a value. The program multiplies the value by 10 and outputs the
result.
Answer:
Flowchart
Pseudocode
start
declare variables
double myNumber
double myAnswer
display Enter a number.
get myNumber
myAnswer = myNumber * 10
display Your number times 10 is , myAnswer
stop
5. Draw a flowchart or write pseudocode to represent the logic of a program that allows
the user to enter a value for the radius of a circle. The program calculates the diameter
by multiplying the radius by 2, and then calculates the circumference by multiplying
the diameter by 3.14. The program outputs both the diameter and the circumference.
Answer:
Flowchart
Pseudocode
start
declare variables
double radius
double diameter
double circumference
display Enter a radius.
input radius
diameter = radius * 2
circumference = diameter * 3.14
display The diameter is , diameter
display The circumference is , circumference
stop
Solutions 1-3
6. Draw a flowchart or write pseudocode to represent the logic of a program that allows
the user to enter two values. The program outputs the sum of the two values.
Answer:
Flowchart
Pseudocode
start
declare variables
double num1
double num2
double answer
display Enter a number
get num1
display Enter another number
get num2
answer = num1 + num2
display The sum of the numbers is , answer
stop
7. Draw a flowchart or write pseudocode to represent the logic of a program that allows
the user to enter three values. The values represent hourly pay rate, the number of
hours worked this pay period, and percentage of gross salary that is withheld. The
program multiplies the hourly pay rate by the number of hours worked, giving the
gross pay; then, it multiplies the gross pay by the withholding percentage, giving the
withholding amount. Finally, it subtracts the withholding amount from the gross pay,
giving the net pay after taxes. The program outputs the net pay.
Answer:
Flowchart
Pseudocode
start
declare variables
double hourlyRate
double numHours
double percentWithheld
double grossPay
double withholdAmt
double netPay
display Enter the hourly rate
get hourlyRate
display Enter the number of hours worked
get numHours
display Enter the percent withheld
get percentWithheld
grossPay = hourlyRate * numHours
withholdAmt = grossPay * percentWithheld
netPay = grossPay - withholdAmt
display The net pay is , netPay
stop
Solutions 1-4