0

Running head: TIP CALCULATION PROGRAM

Running head: TIP CALCULATION PROGRAM

Tip Calculation Program

Dale Lappin

IT210

July 13, 2012

Dan Reddy

TIP CALCULATION PROGRAM

Analysis Section:

1.
2.
3.
4.

Input:

Bill Amount
Tip Percent

Output:

Total Cost

Receive the input from the user
Calculate the tip amount
Calculate total cost
Display the results

(float: > 0.00)
(integer: > 0)

(float: > 0.00)

Input
Name: BillAmount
Type: float
Range: > 0.00

Name:
Type:
Range:
Name:
Type:
Range:
Name:
Type:
Range:

TipPercent
Integer
>0
TotalCost
float
> 0.00
TotalCost
float
> 0.00

Processes
1. InputData

2. CalculateCost

3.DisplayResults

Output
Name: BillAmount
Type: float
Range: > 0.00

Name:
Type:
Range:
Name:
Type:
Range:
Name:
Type:
Range:

TipPercent
Integer
>0
Totalcost
float
> 0.00
Totalcost (Display)
float
> 0.00

Design:

Main Module
Declare BillAmount as float
Declare TipPercent as integer

Call InputData
Call CalculateCost
Call DisplayResults
End Main Module

InputData
Write, “What is the amount of your bill?”
Input BillAmount

Write, “What percent will you be leaving as a tip?”
Input TipPercent
End InputData

CalculateCost
TotalCost = BillAmount * (TipPercent / 100)
End CalculateCost

DisplayResults
Display “The total cost including tip is $” TotalCost
End DisplayResults

0

Associate Program Material

Associate Program Material

Appendix D

Software Development Activities and Purposes

Match the activity or purpose on the left with the appropriate description on
the right by typing in the corresponding letter under the Answer column.

Activity or Purpose
1. Modular Programming

2. Pseudocode

3. Problem Analysis

Answer

J

K

I

4. Program Design

5. Program Coding

G

F

6. Control Structures

D

7. Graphical User Interface

H

8. Event-Driven
Programming

9. Program Testing

10. Hierarchy Charts

B

C

A

11. Flowcharts

E

Description
A. Describes the relationships
between a program’s modules
B. Statements that determine
execution paths of a program
C. Running a program using
various sets of inputs to
determine if the program is
running properly
D. User actions that determine
the flow of program execution
E. Diagram that uses special
symbols to pictorially display
program flow of execution
F. Translating design into
statements that are usable by
the computer
G. Creating a detailed
description of a program using
charts or ordinary language
H. Program interface that allows
the user to make choices with a
mouse, icons, and dialog boxes
I. Identifying desired outputs
based on provided input
J. Process of identifying major
tasks that a system must
accomplish
K. English-like statements to
document the outline of a
program

0

Processes:

Processes:

1.
2.
3.
4.
5.
6.
7.

Prompt the user to enter the employee’s name.
Prompt the user to enter the employee’s salary.
Prompt the user to enter 0 (zero) to end the program and total the average.
Do not store zero
Find the total average of all the employees’ salaries.
Find the total amount of salaries above and below the mean (average) salary.
Display the average salary and the salaries above and below the mean (average)

Input:
Employee’s name
Employee’s salary

Output:
Average salary
Employees making above the mean
Employees making below the mean

Pseudocode:

Main Module
Declare Names as string
Declare Salary as float
Declare sums as float
Declare Count as integer
Call Input Module
Call Find Average Module
Call Display Module
End Main Module

Input Module
Write “Enter Employee’s Name and Salary.”
Write “Enter 0 when done.”
Input Name
Input Salary
Set Sum = 0
Set Mean1 = 0
Set K = 1
While Salary > “0”
Set Mean1 = Count1 + 1
Set Sum = Sum + Salary

(string: data a…z)
(float > 0.00)

(float > 0.00)
(Integer = > 0)
(Integer = > 0)

Write “Enter another Employee’s Name and Salary (enter 0 when done)”
Input Name
Input Salary
End While
End Input Module

Find Average Module
Declare Counts as integer
Declare Salary as float
Declare K as integer
Declare Average as float
Set Average = Sum / Count1
Set Count2 = 0
Set Count3 = 0
For K = 1 Step 1 to Count1
If Salary[K] > Average Then
Set Count2 = Count2 + 1
End If
If Salary[K] < Average Then
Set Count3 = Count3 + 1
End If
End For
End Find Average Module

Display Module
Write “The Average Salary is: $”, Average
Write “The number of Salaries Above the Average Salary is:”, Count2
Write “The number of Salaries Below the Average Salary is:”, Count3
End Display Module

0

Week Eight CheckPoint

Week Eight CheckPoint: Object-Oriented Data and Processes

1. Identify a task you perform regularly, such as cooking, mowing the lawn, or
driving a car.

What task are you going to describe? Let’s make a cup of tea.

2. Write a short, structured design (pseudocode only) that accomplishes this task.

You need to follow proper design principals

Main Module
Call Boil_Water Module
Declare Sugar as an Integer
Sugar = Call How_Many_Sugar Module
Call Prepare_Cup module
End Main Module

Boil_Water Module
Declare Temperature as Integer
If Temperature < 212 degrees Fahrenheit
Turn Heat on
Display “Water is not ready”
Else If Temperature = 212 degrees Fahrenheit
Turn Heat off
Display “Water is ready.”
End Boil_Water Module

Integer How_Many_Sugar Module
Declare Integer Sugar
Display “Enter How Many Teaspoon(s) of Sugar”
Input Sugar
End How_Many_Sugar Module

Prepare_Cup Module
Declare Tea_Flavor as String
Display “What flavor of tea do you want?”
Input Tea_flavor
Display “Adding Boiling Water”
Display “Added” Tea_flavor “to cup.”
Display “Added” Sugar “teaspoons of sugar to cup”
Display “Stirring Tea”
Display “Tea is ready to drink”
End Prepare_Cup Module

3. Think about this task in an object-oriented way, and identify the objects involved
in the task.
1. Teapot

2. Water

3. Cup

4. Tea flavor

5. Sugar

4. Identify how you can encapsulate the data and processes you identified into an
object-oriented design.
The teapot is the object and when the water is added and heat is turned on the
process of making a cup of tea begins. The water communicates back and forth
telling the program the temperature of the water and when it is ready to proceed.
Next the user will send messages to the program so it knows the amount of sugar
and the flavor of tea.

5. Describe the architectural differences between the object-oriented and structured
designs. Which of the designs makes more sense to you? Why?

Object oriented programming can store data and send messages to other
objects. They can also receive messages from other objects. Object oriented
program is much more intuitive for real life situations rather than architectural
programing.
Object oriented design makes more sense to me, because it resembles real life
and it makes the code reusable which could save time.

0

Associate Program Material

Associate Program Material

Appendix G

Sequential and Selection Process Control Structure

In the following example, the third line of the table specifies that the fine on a speeding
ticket that is 11 MPH over the speed limit is $75.00 plus 150% of the MPH over the speed limit,
the court cost is 40% of the fine, and the total fine is the sum of the fine and the court cost.
Therefore, the fine on a speeding ticket that is 11 MPH over the speed limit is $75 + (11 * 1.5) =
$91.50, the court cost is 91.50 * .4 = $36.60, and the total fine is $128.10.
MPH Over Speed
Limit
Fine
Court Cost Total Fine
0 – 4 MPH
$25 + 100% of MPH over speed limit
20% of fine Fine + Court Cost
5 – 9 MPH
$50 + 125% of MPH over speed limit
30% of fine Fine + Court Cost
10 – 14 MPH
$75 + 150% of MPH over speed limit
40% of fine Fine + Court Cost
15 – 19 MPH
$100 + 175% of MPH over speed
50% of fine Fine + Court Cost
limit
20+ MPH
$150 + 200% of MPH over speed
75% of fine Fine + Court Cost
limit

Use these test values for the design walkthrough.

Test Values

Input(overlimit)
3 MPH
7 MPH
12 MPH
18 MPH
25 MPH

Fine

25 + (3 * 1) =28
50 + (7 *1.25) = 58.75
75 + (12 * 1.5) = 93
100 + (18 * 1.75) = 131.50
150 + (25 * 2) = 200

Court cost
28 * .2 = 5.60
58.75 * .3 = 17.63
93 * .4 = 37.20
131.50 * .5 = 65.75
200 * .75 = 150

Total

28 + 5.60 = $33.60
58.75 + 17.63 = $76.38
93 + 37.20 = $130.20
131.5 + 65.75 = $197.25
200 + 150 = $350.00

You must use the Selection Control structure to determine the calculation for the different
MPH over the speed limit ranges.

Analysis:
1. Receive input (OverLimit) from user
2. Calculate Fine
3. Calculate CourtCost
4. Display TotalFine

Input

OverLimit (integer: >0)

Output

TotalFine (float >0.00)

Input
Name: OverLimit
Type: Integer
Range: >0

Name: Fine
Type: float

Processes
1.InputData

2.CalculateCost

Output
Name: Fine
Type: Integer
Range: >0

Name: TotalFine
Type: float

Appendix G
IT/210 Version 5

2

MainModule
Declare OverLimit as integer
Declare Fine as float
Declare TotalFine as float

Call InputData
Call CalculateCost
Call DisplayTotal
End MainModule

InputData
Write, “Enter MPH over the speed limit”

Input OverLimit
End InputData

CalculateCost
IF OverLimit = < 4
THEN Fine = 25 + OverLimit / 100
CourtCost = Fine * 20 / 100
ELSE IF OverLimit = 5 < 9
THEN Fine = 50 + OverLimit / 125
CourtCost = Fine * 30 / 100
ELSE IF OverLimit = 10 < 14
THEN Fine = 75 + OverLimit / 150
CourtCost = Fine * .4
ELSE IF OverLimit = 15 < 19
THEN Fine = 100 + OverLimit / 175
CourtCost = Fine * .5
ELSE IF OverLimit = > 20
THEN Fine = 150 + OverLimit / 200
CourtCost = Fine * .75
End IF
TotalFine = Fine + CourtCost
End InputData

DisplayTotal
Display “The total fine after court cost is $”TotalFine

Appendix G
IT/210 Version 5

3

End DisplayTotal

0

Week 4 CheckPoint

Week 4 CheckPoint – Repetition and Decision Control Structures

In one of the week 3 discussion questions we discussed the algorithm that
would be required to make a peanut butter sandwich. In this CheckPoint you
will need to take that one step further and create a program design to make
peanut butter sandwiches.

Below you will find a partial program design; you need to complete it by adding
the pseudocode in the required areas. You need to add one repetition (loop)
control structure and one decision control structure to complete the program
design. The user will decide how many sandwiches are made; this is where the
loop will be used. The user will also decide if the sandwich includes jelly, and,
if it does, what flavor of jelly; to keep it simple we are only allowing grape or
strawberry jelly.

Analysis

Process:
1.
2.
3.
4.

Ask user how many sandwiches to make
If the user enters 0 for number of sandwiches the program should end
Ask user if they want jelly on their sandwich
If jelly is requested, ask user what flavor (grape or strawberry) of
jelly they would like
5. Make sandwiches

Input:

numberOfSandwiches
includeJelly
typeOfJelly

Output:
Sandwich

Design

Main Module

Declare numberOfSandwiches as integer
Declare includeJelly as string
Declare typeOfJelly as string
Declare continue as Boolean
Set continue to true

Do While continue = true
Call InputModule
EndDo

(integer)
(string; values Yes/No)
(string; values Grape/Strawberry)

End Main Module

InputModule

Display “How many sandwiches would you like to make? Enter 0 to end
program.”
Input numberOfSandwiches

If numberOfSandwiches = 0
Set continue = false
Else
Display “Do you want jelly on your sandwiches?”
Input includeJelly

If includeJelly = “Yes”
Display “What type of jelly; Grape or Strawberry?”
Input typeOfJelly
EndIf
While numbreOfSandwiches > 0
Subtract 1 from numberOfSandwiches
Call SandwichModule
EndWhile
EndIf

End InputModule

SandwichModule

Get bread
Spread peanut butter on bread
If includeJelly = “Yes”
Get bread
Call typeOfJelly
Spread typeOfJelly on bread
Join the two slices of bread
Else If includeJelly = “No”
Get bread
Join the two slices of bread
EndIf
Call InputModule

End SandwichModule

0

Running head

Running head: INTERFACES AND COMMUNICATION MESSAGES

1

Interfaces and Communication Messages

Dale Lappin

IT210

August 22, 2012

Dan Reddy

INTERFACES AND COMMUNICATION MESSAGES

2

Top Level

Objects

Interfaces and Communication Messages

Communicates

With

Incoming

Messages

Outgoing

Messages

Open

Door

Control Panel

Control

Panel

Door

Microwave Controller

Display Panel

Microwave

Controller

Control

Panel

Display

Panel

Control

Panel

Open

Closed

Power On

Power Off

Start

Stop

Temperature Settings

Temperature Settings

Power On

Power Off

Time

Closed

Time

Start

Clear

Temperature Settings

Temperature

Power On

Power Off

Describe some of the advantages of having a componentized system.
(For example, what happens if the microwave breaks?)

One advantage of a componentized system is that if one component breaks then you can just replace
the broken component and not the whole system. A real life example of this would be a home stereo
system, having separate components such as the amplifier, equalizer, tuner, and a CD player makes
it possible to replace only the broken component. In the kitchen model, the microwave itself is a
component of the kitchen, if it breaks there is no need to replace the whole kitchen just the microwave.

0

Associate Program Material

Associate Program Material

Appendix C

Input Data and Output Process

In the Processes column, list at least three processes (capabilities) necessary to keep track of
your home CD or DVD collection on your computer. You will be the user of the program; you
need to define the processes you would like to see in the program.

In the Input column, identify a logical name (variable) for the input data required for each
process the type of output data: real, integer, or text.

In the Output column, identify a logical (variable) name for each output data item and the
type of output data: real, integer, or text.

You can have more than one input/output variable for each process. Make sure you define the
logical name and data type for each variable. In this assignment you do not need to define the
range for each input/output variable.

Make sure you review the example provided in Appendix B in the Course Materials Forum.

Input
Name: CD or DVD
Type: Integer
Range: >0

Name: Artist
Type: Text
Range:

Name: Title
Type: Text
Range:

Name: Genre
Type: Text
Range:
Name: Year
Type: Integer
Range: >0

Processes
1. Display Total

2. Search by Artist

3.Search by Title

4. Search by Genre

5. Search by Year

Output
Name: Total
Type: Integer
Range: >0

Name: Artist list
Type: Text
Range:

Name: Title list
Type: Text
Range:

Name: Genre list
Type: Text
Range:
Name: Year Released list
Type: Integer
Range: >0

0

Running head

Running head: CHAPTER 8 PROGRAMMING PROBLEMS

Chapter 8 Programming Problems

Dale Lappin

IT210

08/17/2012

Daniel Reddy

CHAPTER 8 PROGRAMMING PROBLEMS

Chapter 8 Programming Problems

a) Input names of students from the user, terminated by ”ZZZ”,0,0,0, and create a data file
grades with records of the following form:
Student (String), test1 (Integer), test2 (Integer), test3 (Integer)

Analysis

Input:
1.
2.
3.
4.

Process:
1. Get user input
2. Create GRADES
3. Calculate Grade_Total
4. Create Records

Output:
1. Student
(string)
2. Test1, Test2, Test3 (Integer 1-100)
3. Grade_Total
(Integer 1-300)

Input
Student
String

Name:
Type:
Range:
Name:
Type:
Range:

Test1
Integer
1-100

Name: Test2
Type: Integer
Range: 1 -100

Name:
Type:
Range:
Name:
Type:
Range:

Test3
Integer
1 -100
Student
String

Student
Test1
Test2
Test3

(string)
(Integer 1-100)
(Integer 1-100)
(Integer 0-100)

Processes
1.InputData

2.CalculateTotal

Output
Student
String

Name:
Type:
Range:
Name:
Type:
Range:

Grade_Total
Integer
1-300

3. DisplayResult

Name: Test1, Test2, Test3
Type: Integer
Range:1-100

Name: Grade_Total
Type: Integer
Range: 1-300

Name: Student (Display)
Type: String
Range:

Name: Test1, Test2, Test3
(Display)
Type: Integer
Range: 1-100

Name: Grade_Total (Display)
Type: Integer
Range: 1-300

CHAPTER 8 PROGRAMMING PROBLEMS

MainModule
Open GRADES
Declare Student as string
Declare Test1 as integer
Declare Test2 as integer
Declare Test3 as integer
Declare Grade_Total as integer
Close GRADES

Call InputData
Call CalculateGradeTotal
Call DisplayResults
End MainModule

InputData
Display “Enter Student’s name, ZZZ to quit”
Input Student
While Student < > “ZZZ”
Write Student to GRADES
Input Test1
Write“Test1” to GRADES

CHAPTER 8 PROGRAMMING PROBLEMS

Input Test2
Write “Test2” to GRADES
Input Test3
Write “Test3” to GRADES
Write newline to GRADES
End While
End InputData

CalculateTotal
Read Test1 from GRADES
Read Test2 from GRADES
Read Test3 from GRADES
Declare Grade_Total as Integer
Total Score = Test Score1 + Test Score2 + Test Score3
Write “Grade_Total” to GRADES
End CalculateTotal

b) Display the contents of the file grades created in Part a. Each student’s record should
appear on a separate line and include the total score (the sum of the three tests) for that
student. For example, a line of output might be as follows:

R. Abrams 76 84 82 242

Input
Name: Student
Type: String
Range:

Name: Test1, Test2, Test3
Type: Integer
Range:1-100

Name: Grade_Total
Type: Integer
Range: 1-300

Processes
3. DisplayResult

Output
Name: Student (Display)
Type: String
Range:

Name: Test1, Test2, Test3
(Display)
Type: Integer
Range: 1-100

Name: Grade_Total (Display)
Type: Integer
Range: 1-300

CHAPTER 8 PROGRAMMING PROBLEMS

DisplayResults
Read Student from GRADES
Read Test1 from GRADES
Read Test2 from GRADES
Read Test3 from GRADES
Read Grade_Total from GRADES
Display Student “test scores” Test1, Test2, Test3 “=” Grade_Total
Write newline to Grades
End DisplayResults

0

Associate Program Material

Associate Program Material

Appendix J

Algorithm Verification

Consider the following selection statement, where testScore is an integer test score between 0
and 100.

declare testScore as Integer; values 0-100
input testScore
if (0 <= testScore and testScore < 49)
output “You fail.”
else if (50 <= testScore and testScore < 70)
output “Your grade is” testScore
output “You did OK.”

else if (70 <= testScore and testScore < 85)
output “Your grade is” testScore
output “You did well.”
else if (85 <= testScore and testScore < 100)
output “Your grade is” testScore
output “You did great.”
endif
output “How did you do?”

Answer the following questions:

• What will be printed if the input is 20?
“You Fail.” Will be printed because:
if (0 <= testScore and testScore < 49)
output “You fail.”
• What will be printed if the input is 100?
“How did you do?” will be printed.

• What will be printed if the input is 73?
“Your grade is” 73 “You did well.” Will be printed because:
else if (70 <= testScore and testScore < 85)
output “Your grade is” testScore
output “You did well.”

• What will be printed if the user enters “score”?
“score” Will cause an error. “How did you do?” could be printed again

• Is this design robust? If so, explain why. If not, explain what you can do to make it robust.
This design is not robust because there is no statement for error or exception handling. To
make it more robust I would add a statement like the user can only enter integers from 0
to 100. If the user enters other numbers or data types they will get an error or an invalid
message such as like “Invalid entry. Enter a number from 0 to 100” It also doesn’t handle the
case of entering 49. It should be: else if (49 <= testScore and testScore < 70), because as it is
now, when 49 is entered all it will say is “How did you do?” The same thing will happen when
entering 100, else if (85 <= testScore and testScore <= 100) would fix this problem.

How many levels of nesting are there in this design?

Appendix J
IT/210 Version 5

2

There is no nesting.
• Provide a set of values that will test the normal operation of this program segment. Defend
your choices.
Any number from 0 to 100 will test the normal operation of this program because the algorithm
only covers that code.

• Provide a set of test values that test the abnormal operation of this program segment.
Test values that will test abnormal operation would be:
Negative values such as “-20” or any number that is < 0
A numerical value that is > 100 such as “120” or
String values such as “score”
Any value that is not between 0 through 100 will check the abnormal operation of this program
segment.