0% found this document useful (0 votes)
90 views

Assignemnt 3 of Problem Solving

This document contains the solutions to 5 programming exercises. It includes pseudocode for: 1) A program that allows a user to order items from a menu and calculates the total cost. It uses arrays to store the item prices and names. 2) A program that allows a user to enter a team number and displays the corresponding team name. It uses an array to store the team names. 3) An expanded version of the previous program that also counts the number of times each team is selected and displays the results. It uses two arrays, one to store team names and another to store the selection counts.

Uploaded by

Kaladher Reddy
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
90 views

Assignemnt 3 of Problem Solving

This document contains the solutions to 5 programming exercises. It includes pseudocode for: 1) A program that allows a user to order items from a menu and calculates the total cost. It uses arrays to store the item prices and names. 2) A program that allows a user to enter a team number and displays the corresponding team name. It uses an array to store the team names. 3) An expanded version of the previous program that also counts the number of times each team is selected and displays the results. It uses two arrays, one to store team names and another to store the selection counts.

Uploaded by

Kaladher Reddy
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 12

ASSIGNMENT # 3

by
gurram kaladhar reddy & nishtala sandeep

True or False:
1.f
2.f
3.f
4.f
5.f
multiple choice:
1.a
2.a
3.a
4.b
short answers:
1. Accumulator is a variable that gathers values
Silmilar to a counter Counter increments by 1. Accumulator increments by some value
Accumulators require three actions actions
Initialize the accumulator to 0
Accumulators are altered: once for every data set processed
At the end of processing, accumulators are output
2. we create array constants by entering a list of items and then manually surrounding the
list with braces { }
3. we find a particular value in an array by using some searching techniques on that array.












exercise 4:




Pseudocode:

start
Declarations
string itemOrdered
num x
num found = 0
num total = 0
num SIZE = 3
string QUIT = ZZZZ
num PRICE[SIZE] = 2.49, 1, 0.59
string PRODUCT[SIZE] = Cheeseburger, Pepsi, Chips
string ERROR_MSG = Sorry, we do not carry that
getReady()
while itemOrdered not equal to QUIT
detailLoop()
endwhile
finishUp()
stop

getReady()
output Enter an item or , QUIT, to complete your order
input itemOrdered
return

detailLoop()
found = 0
x = 0
while x < SIZE
if itemOrdered = PRODUCT[x] then
output PRICE[x]
x = SIZE
found = 1
total = total + PRICE[x]
else
x = x + 1
endif
endwhile
if found = 0 then
output ERROR_MSG
endif
output Enter an item or , QUIT, to complete your order
input itemOrdered
return

finishUp()
output Your order total is: $, total
return
exercise 5:

A:


Pseudocode:

start
Declarations
num teamNum
num QUIT = -1
num SIZE = 5
string teams[SIZE] = Goal Getters, The Force,
Top Guns, Shooting Stars,
Midfield Monsters
getReady()
while teamNum not equal to QUIT
displayTeamName()
endwhile
finishUp()
stop

getReady()
output Enter the players team number or , QUIT, to quit
input teamNum
return

displayTeamName()
if teamNum >= 1 AND teamNum <= SIZE then
output teamNum, teams[teamNum-1]
else
output Invalid team number
endif
output Enter the players team number or , QUIT, to quit
input teamNum
return

finishUp()
output End of program
return













B:



Pseudocode:

start
Declarations
num teamNum
num QUIT = -1
num SIZE = 5
num teamCnt[SIZE] = 0
string teams[SIZE] = Goal Getters, The Force,
Top Guns, Shooting Stars,
Midfield Monsters
getReady()
while teamNum not equal to QUIT
countTeams()
endwhile
finishUp()
stop

getReady()
output Enter the players team number or , QUIT, to quit
input teamNum
return

countTeams()
if teamNum >= 1 AND teamNum <= SIZE then
output teamNum, teams[teamNum-1]
teamCnt[teamNum-1] = teamCnt[teamNum-1] + 1
else
output Invalid team number
endif
output Enter the players team number or , QUIT, to quit
input teamNum
return

finishUp()
teamNum = 0
while teamNum < SIZE
output teamNum+1, teamCnt[teamNum]
teamNum = teamNum + 1
endwhile
return

You might also like