100% found this document useful (1 vote)
147 views9 pages

1090C Computer Programming I Lab 1 - Flow Charts and Pseudo Code SPRING 2020 10 Pts / 2 Extra Pts

Uploaded by

Mike Ahlers
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
147 views9 pages

1090C Computer Programming I Lab 1 - Flow Charts and Pseudo Code SPRING 2020 10 Pts / 2 Extra Pts

Uploaded by

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

1090C Computer Programming I

Lab 1 – Flow Charts and Pseudo Code


SPRING 2020
10 pts / 2 extra pts

Labs are never about getting done… They are about learning.

I often will include a short mini-lecture at the start of the lab directions. This is designed to
focus your attention on the learning goals for the lab and often provides you with specific
technical details you will practice directly in the lab session.
Mini-lecture:

We use pseudo code and flow charts to capture the logic of a program prior to implementing it
with code. In general practice, flow charts are too cumbersome for large programs/systems and
so they are mainly used for isolated sub-routines, and high-level architectural patterns, etc.

We use pseudo code all the time. The pseudo code outline we write initially becomes the
documentation for the completed program. To code the program, we go through and write the
program code that corresponds to the pseudo code outline. The outline then becomes the
program comments that document the code.

Students rarely believe me initially when I mention that the important part of this process is the
generation of the pseudo code outline. Generating the code that corresponds to the outline is
trivial and simply a matter of practice with the language syntax. If the pseudo code outline is
incorrect then the program code will not correctly solve the task. Instead of trying to “write the
program out of your head” as it were, take the time to create a solid and logically clear pseudo
code outline before you begin coding.
Common flowchart symbols:
 Lines (Arrows) show the flow
 Input symbols (parallelograms)
 Processing symbols (rectangles)
 Output symbols (parallelograms)
 Terminal symbols (lozenges – flattened ovals)
 Decision symbols (diamonds)

Start

Copyright © 2019, University of Cincinnati, Ohio. All rights reserved.


output “What is your
favorite Number?”

input favNumber

doubleFun = favNumber * 2

output “Double your fun


is: ” + doubleFun

End

Copyright © 2019, University of Cincinnati, Ohio. All rights reserved.


Pseudo Code:
Pseudo code is informal and fairly close to natural language. Rather than complete sentences,
we tend to use very brief statements which will ultimately translate more directly to program
code. Indentation is used to show groups of related statements, pay attention to it.
Look carefully at the example here and be sure to understand how both the pseudo code and the
flowchart express the same logic (i.e. the same program).
Prompts: In every case, you have to prompt the user so they know what you need for them to
input. Thus, before every input, we output the prompt msg so the user knows what we want to
get from them.

Always include the prompt in your pseudo code and flowcharts when you do input.
Output should always be in the form of a complete sentence, not just a raw calculated
value. i.e. The total calculated building costs is: $560.00.

Example:
start
output “What is your favorite number?”
input favNumber
doubleFun = favNumber * 2
ouput “Double your fun is “ + doubleFun
stop

Lab:
1. Insert your work for the completed lab here within this MS Word document and
submit it as directed at the end of the document.

Copyright © 2019, University of Cincinnati, Ohio. All rights reserved.


A) start
output “Please enter the price of your purchase.”
input yourPurchase
salesTax = yourPurchase * .05
output “The sales tax on your purchase is $” + salesTax
end

start

output “Please enter the


price of your purchase.”

input yourPurchase

salesTax = yourPurchase * .05

output “The sales tax on your


purchase is $” + salesTax

end

Copyright © 2019, University of Cincinnati, Ohio. All rights reserved.


B) start
output “Please enter the height of your rectangle in feet.”
input rectangleHeight
output “Please enter the width of your rectangle in feet.”
input rectangleWidth
rectangleArea = rectangleHeight * rectangleWidth
output “The area of your rectangle is “ + rectangleArea + “ square feet.”
end

start output “The area of your


rectangle is “ + rectangle Area + “
square feet.”

output “Please enter the height of


your rectangle in feet.”
end

Input rectangleHeight

output “Please enter the width


of your rectangle in feet.”

Input rectanlgeWidth

rectangleArea = rectangleHeight *
rectangleWidth

Copyright © 2019, University of Cincinnati, Ohio. All rights reserved.


C) start
output “What is your home maintenance cost for the spring season?”
input springCost
output “What is your home maintenance cost for the summer season?”
input summerCost
output “What is your home maintenance cost for the fall season?”
input fallCost
output “What is your home maintenance cost for the winter season?”
input winterCost
totalCost = springCost + summerCost + fallCost + winterCost
output “Your total yearly home maintenance cost is $” + totalCost
end

start input fallCost

output “What is your home


output “What is your home maintenance cost for the winter
maintenance cost for the spring season?”
season?”

input winterCost
input springCost

totalCost = springCost + summerCost +


output “What is your home fallCost + winterCost
maintenance cost for the summer
season?”

output “Your total yearly home


input summerCost maintenance cost is $” + totalCost

output “What is your home end


maintenance cost for the fall season?”

Copyright © 2019, University of Cincinnati, Ohio. All rights reserved.


D) start
output “Please enter your starting number.”
input startingNumber
output “Please enter the number to be subtracted from your starting number.”
input subtractNumber
finalNumber = startingNumber – subtractNumber
output “Your answer is “ + finalNumber
end

start output “Your answer is “ +


finalNumber

output “Please enter your starting end


number.”

input startingNumber

output “Please enter the number


to be subtracted from your
starting number.”

input subtractNumber

finalNumber = startingNumber -
subtractNumber

Copyright © 2019, University of Cincinnati, Ohio. All rights reserved.


E) start
output “Please enter your credit card balance.”
input creditCardBalance
monthOneInterest = creditCardBalance * .17
monthOneTotal = creditCardBalance + monthOneInterest
monthTwoInterest = monthOneTotal * .17
totInterest = monthOneInterest + monthTwoInterest
output “The interest on your credit card after one month is $” + monthOneInterest
output “The total interest on your credit card after two months is $” + totInterest
end

start totInterest = monthOneInterest +


monthTwoInterest

output “Please enter your credit output “The interest on your


card balance.” credit card after one month is $”
+ monthOneInterest

input creditCardBalance

output “The total interest on


your credit card after two
monthOneInterest = creditCardBalance * . months is $” + totInterest
17

monthOneTotal = creditCardBalance + end


monthOneInterest

monthTwoInterest = monthOneTotal * .17

Copyright © 2019, University of Cincinnati, Ohio. All rights reserved.


A) For each of the following tasks, provide both the flow chart and pseudo code. You
may use the MS Word symbols to create the flow charts or any other tool that lets you
create and embed them in this document. I’ll likely work through the first task with
you during the session. Just insert your response right here in this document. Before
doing the flow chart or pseudo code, list the input(s) and output(s) required for each
program. (Please note that these are all simple programs with no branching so the
flow charts will be a vertical connection of symbols like the example here.)

a. Task 1 (2 pts): a program where the user enters the price of a purchase
and the program computes and outputs a 5% sales tax. Don’t forget the
prompt!

b. Task 2 (2 pts): A program for calculating the area in square feet. (User
will input the height and the width in feet.)

c. Task 3 (3 pts): A program that asks the user to enter home maintenance
costs for each of the four seasons and returns the total yearly
maintenance costs. (Separate prompt and input for each input value!)

d. Task 4 (3 pts): A program that calculates the difference between two


numbers. i.e. subtracts one from the other. Thus this might be a negative
value.

e. Task 5 (2 pts Extra Credit): A program where the user enters a credit
card balance and the program calculates the interest at a rate of 17%
monthly. Assume the user does not make any payment. Display the
interest due after one month and again after two months.

B) Submitting your work: carefully check your work.

You need to follow directions and develop professional work habits. I’m very
specific about how I want the work submitted especially with the naming and the
format of files so they can be tracked efficiently. If you can’t or won’t follow
directions, you work will not be graded and you receive no credit.

Rename your copy of this word file as Lastname_Firstname_Lab01.docx using


your name. Submit this file using the Canvas assignment mechanism. Submit the
exact same file a second time using the additional Canvas link for the extra credit
option.

Copyright © 2019, University of Cincinnati, Ohio. All rights reserved.

You might also like