In this assignment, I was asked to create flowcharts from psuedocode and vice versa. Questions 7 and 8 required me to design a program and psuedocode from a brief description of what the program needed to do. This shows my understanding of programming logic, as well as designing flowcharts and psuedocode.
1. Use the structured flowchart below to write a structured Pseudocode. (1 Point)
Start
Declarations
num policyNumber
num age
num dueMonth
num dueDay
num dueYear
num accidents
string lastName
string firstName
input policyNumber, lastName, firstName, age, dueMonth, dueDay, dueYear, accidents
if policyNumber < 1000 OR policyNumber > 9999 then
policyNumber = 0
endif
if dueMonth < 1 OR dueMonth > 12 OR dueDay < 1 OR dueDay > 31 then
dueMonth = 0
dueDay = 0
dueYear = 0
else
if (dueMonth = 2 AND dueDay > 29) OR ((dueMonth = 4 OR dueMonth = 6 OR dueMonth = 9 OR
dueMonth = 11) AND dueDay > 30) then
dueMonth = 0
dueDay = 0
dueYear = 0
else
output policyNumber, lastName, firstName, age, dueMonth, dueDay, dueYear, accidents
endif
endif
stop
2. Use the structured Pseudocode below to design a structured flowchart. (1 Point)
start
Declarations
num policyNumber
num age
num dueMonth
num dueDay
num dueYear
num accidents
string lastName
string firstName
Input
policyNumber,
lastName,
firstName, age,
dueMonth,
dueDay,
dueYear,
accidents
age > 35?
Output
policyNumber,
lastName,
firstName, age,
dueMonth,
dueDay,
dueYear,
accidents
stop
yes
no
3. Use the structured flowchart below to write a structured Pseudocode. (1 Point)
Start
Declarations
num policyNumber
num age
num dueMonth
num dueDay
num dueYear
num accidents
string lastName
string firstName
input policyNumber, lastName, firstName, age, dueMonth, dueDay, dueYear, accidents
if dueMonth < 3 OR (dueMonth = 3 AND dueDay <= 15) then
output policyNumber, lastName, firstName, age, dueMonth, dueDay, dueYear, accidents
endif
stop
4. Use the structured Pseudocode below to design a structured flowchart. (1 Point)
start
Declarations
num policyNumber
num age
num dueMonth
num dueDay
num dueYear
num accidents
string lastName
string firstName
input policyNumber,
lastName, firstName,
age, dueMonth, dueDay,
dueYear, accidents
dueYear < 2011 OR (dueYear =
2011 AND dueDay = 1 AND
dueMonth = 1)?
output policyNumber,
lastname, firstName,
age, dueMonth, dueDa,
dueYear, accidents
stop
yes
no
5. Use the structured flowchart below to write a structured Pseudocode. (1 Point)
start
Declarations
num idNumber
num dogAge
num dogWeight
num fee
string dogName
string dogBreed
num SMALL_FEE = 55
num MED_FEE = 75
num LARGE_FEE = 105
num XLARGE_FEE = 125
input idNumber, dogName, dogBreed, dogAge, dogWeight
if dogWeight < 15 then
fee = SMALL_FEE
else
if dogWeight <= 30 then
fee = MED_FEE
else
if dogWeight <= 80 then
fee = LARGE_FEE
else
fee = XLARGE_FEE
endif
endif
endif
output idNumber, dogName, dogBreed, dogAge, dogWeight, fee
stop
6. Use the structured Pseudocode below to design a structured flowchart. (1 Point)
start
Declarations
num orderNum
num deskLength
num deskWidth
num numDrawers
num price
string custName
string woodType
num MIN_FEE= 200
num LARG_FEE = 50
num OAK_FEE = 125
num DRAWER_FEE = 30
input orderNum,
custName, deskLength,
deskWidth,
numDrawers, woodType
eof?
woodType = oak AND
numDrawers >= 1 AND
(deskLength * deskWidth) >
36?
price = MIN_FEE + OAK_FEE
price = price + numDrawers *
DRAWER_FEE
deskLength * deskWidth >
750?
price = price + LARGE_FEE
output orderNum,
custNum, deskLength,
deskWidth,
numDrawers, price,
woodType
stop
input orderNum,
custNum, deskLength,
deskWidth,
numDrawers, woodType
7. Black Dot Printing is attempting to organize carpools to save energy. Each input record contains an employee s name and town of residence. Ten percent of the
company s employees live in Wonder Lake; 30 percent live in Woodstock. Because these towns are both north of the company, Black Dot wants to encourage employees
who live in either town, to drive to work together. Design a flowchart or pseudocode for following:
A program that accepts an employee s data and displays it with a message that indicates whether the employee is a candidate for the carpool. (2 Points)
start
Declarations
string employeeName
string employeeTown
string message
input employeeName, employeeTown
if employeeTown = Wonder Lake OR (employeeTown = Woodstock ) then
output employeeName, employeeTown, message
endif
stop
8. Pastoral College is a small college in the Midwest. Design a flowchart or Pseudocode for following:
A program that accepts a student s data: an ID number, first and last name, major field of study, and grade point average. Display a student s data if the student s
grade point average is below 2.0. (2 Points)
start
Declarations
num idNumber
num gpa
string firstName
string lastName
string fieldStudy
input idNumber, gpa, firstName, lastName, fieldStudy
if gpa < 2.0 then
output idNumber, gpa firstName, lastName, fieldStudy
endif
stop