8

Click here to load reader

Project 3 - Intro to Programming Logic

Embed Size (px)

Citation preview

Page 1: Project 3 - Intro to Programming Logic

Use the structured flowchart below to write a structured Pseudocode. (1 Point)

StartDeclarations

num policyNumbernum agenum dueMonthnum dueDaynum dueYearnum accidentsstring lastNamestring firstName

input policyNumber, lastName, firstName, age, dueMonth, dueDay, dueYear, accidentsif policyNumber < 1000 OR policyNumber > 9999 then

policyNumber = 0endifif dueMonth < 1 OR dueMonth > 12 OR dueDay < 1 OR dueDay > 31 then

dueMonth = 0dueDay = 0dueYear = 0

elseif (dueMonth = 2 AND dueDay > 29) OR ((dueMonth = 4 OR dueMonth = 6 OR dueMonth = 9 OR dueMonth = 11) AND dueDay > 30) then

dueMonth = 0dueDay = 0dueYear = 0

elseoutput policyNumber, lastName, firstName, age, dueMonth, dueDay, dueYear, accidents

endifendif

stop

Page 2: Project 3 - Intro to Programming Logic

Use the structured Pseudocode below to design a structured flowchart. (1 Point)

start

Declarationsnum policyNumber

num age num dueMonth

num dueDaynum dueYear

num accidentsstring lastNamestring firstName

Input policyNumber,

lastName, firstName, age,

dueMonth, dueDay, dueYear, accidents

age > 35?

Output policyNumber,

lastName, firstName, age,

dueMonth, dueDay, dueYear, accidents

stop

yes

no

Page 3: Project 3 - Intro to Programming Logic

Use the structured flowchart below to write a structured Pseudocode. (1 Point)

StartDeclarations

num policyNumbernum agenum dueMonthnum dueDaynum dueYearnum accidentsstring lastNamestring firstName

input policyNumber, lastName, firstName, age, dueMonth, dueDay, dueYear, accidentsif dueMonth < 3 OR (dueMonth = 3 AND dueDay <= 15) then

output policyNumber, lastName, firstName, age, dueMonth, dueDay, dueYear, accidentsendif

stop

Page 4: Project 3 - Intro to Programming Logic

Use the structured Pseudocode below to design a structured flowchart. (1 Point)

start

Declarationsnum policyNumber

num agenum dueMonth

num dueDaynum dueYearnum accidents

string lastNamestring 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

Page 5: Project 3 - Intro to Programming Logic

Use the structured flowchart below to write a structured Pseudocode. (1 Point)

startDeclarations

num idNumbernum dogAgenum dogWeightnum feestring dogNamestring dogBreednum SMALL_FEE = 55num MED_FEE = 75num LARGE_FEE = 105num XLARGE_FEE = 125

input idNumber, dogName, dogBreed, dogAge, dogWeightif dogWeight < 15 then

fee = SMALL_FEEelse

if dogWeight <= 30 thenfee = MED_FEE

elseif dogWeight <= 80 then

fee = LARGE_FEEelse

fee = XLARGE_FEEendif

endifendifoutput idNumber, dogName, dogBreed, dogAge, dogWeight, fee

stop

Page 6: Project 3 - Intro to Programming Logic

Use the structured Pseudocode below to design a structured flowchart. (1 Point)

start

Declarationsnum orderNumnum deskLengthnum deskWidth

num numDrawersnum price

string custNamestring woodType

num MIN_FEE= 200num LARG_FEE = 50num 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

Page 7: Project 3 - Intro to Programming Logic

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)

startDeclarations

string employeeNamestring employeeTownstring message

input employeeName, employeeTownif employeeTown = Wonder Lake OR (employeeTown = Woodstock ) then

output employeeName, employeeTown, messageendif

stop

Page 8: Project 3 - Intro to Programming Logic

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)

startDeclarations

num idNumbernum gpastring firstNamestring lastNamestring fieldStudy

input idNumber, gpa, firstName, lastName, fieldStudyif gpa < 2.0 then

output idNumber, gpa firstName, lastName, fieldStudyendif

stop