Benja303

02-24-2013, 04:30 AM

Hi, I'm doing an assignment and i am VERY confused.

I have read my notes, watched youtube vids and used my books but i still feel like i have a gap in my Knowledge somehow.

Here are my instructions

HERE ARE MY INSTRUCTIONS

What started out as a little “baking on the side” for Della has now become a full-time venture. She has recently opened Della’s Delectable Delights, a bakery and café selling pastries and other baked goods. However, she needs some assistance in managing the numerous orders she gets on a daily basis.

She wishes you to design a system which will help her to manage orders for her specialty items: Not-so-salt Bread, Jam Jump-ups and Coconut Cravers.

At the end of each day, Della wants to enter the orders (in no particular sequence) which have come in for the following day. Each of the three specialty items need to be dealt with differently and your system must be able to handle the requirements.

1) Not-so-salt Bread: Often, customers can’t wait to get their hands on their Not-so-salt Bread and call to enquire if their order would be ready for early collection. Therefore, once Brenda has completed a Not-so-salt Bread order, she places the customer ID on the Bread Completion List. Della is then able to search the list for the ID of the enquiring customer. You may assume there are a maximum of 20 separate customer orders for Not-so-salt Bread; Binary Search is required – assume list is in descending order.

2) Jam Jump-ups: Janine and Jerry handle all of the orders for Jam Jump-ups. Any orders which are over 25 are handled by Janine; all others are handled by Jerry. The system will be required to separate and allocate the orders to the appropriate baker. Once all of the orders have been allocated, the sorted list for each baker should be displayed along with a total number of Jam Jump-ups for each baker. You may assume there are a maximum of 10 separate customer orders for Jam Jump-ups; Selection Sort is required – assume ascending order.

3) Coconut Cravers: Colin and Connie are the most competitive Coconut Craver creators you will ever come across. There is always a challenge to see who will make the most Coconut Cravers and be Coconut Craver Champion at the end of each day. Therefore, the list of orders should be printed for them with the largest first so that whoever completes their current order first, may pull the next largest. You may assume there are a maximum of 15 separate customer orders for Coconut Cravers; Bubble Sort is required.

INSTRUCTIONS

1. Create a single algorithm to handle the requirements.

2. You must define and use at least two functions.

_____

Okay so basically, I have to follow the instructions, but I CANNOT USE GLOBAL VARIABLES. So doesn't that mean that my ENTIRE program will have to be a complilation of functions?

Here is my Psuedocode (Part of it)

___

Begin Algorithm

¬Function PopulateArray ()

Declare variable I as integer

Declare constant NSSbSize=20

Declare Array CustomerID to hold 20 Integer Values

Declare Integer Array NSSBorder of size NSSbSize

I=0

For I=0 to NSSbSize-1

Display “Please enter the ID of the Customer”

Read CustomerID[i]

Display “Please enter Order.”

Input NSSBOrder[i]

End Function

Function BreadCompList (CustomerID )

Display “Is this Customers [CustomerID[i]] order complete? (Yes/No) ”

Input Choice

Declare variable Choice as string

If Choice=”yes” THEN

CustomerID[i] =BCList[ i]

EndIf

End Function

// Defining binary search function

Function BinarySearch (BCList[i], CustomerID[i],NSSBsize)

BEGIN

Declare min, max, mid, search key as Integer

“Please enter the ID of the Customer whose order you are checking on.”

Input CustomerID

Searchkey:=0

Min:=0

Max:=NSSBsize-1

WHILE max >= min DO

Mid:=(min+max) div2

IF BCList[mid] = searchkeyTHEN

Display “ This Order is ready.”

Stop?

ELSE IF searchKey < BCList [mid] THEN

Max:=mid-1

Else

Min:=Mid+1

EndIf

Endwhile

Display “This order is not ready.”

Endfucntion

//Defining swap function

Function Swap ( JenOrder[i], JenOrder[J] )

Begin

Temp= JenOrder[i]

JenOrder[i]=JenOrder[minI]

JenOrder[minI]=temp

EndFunction

¬¬¬¬¬ // Define Selection sort function

Function SelectionSort (JJUsize, JenOrder[i] bring in a counter?)

Begin

Declare MinI, J as data type integer

MinI=0

J=0

FOR i=0 to JJUSize-1 DO

FOR J=i + 1 to arraySize-1 DO

IF (JenOrder[j] < JenOrder[MinI]

MinI=J

IF (minIndex !=i) THEN

Swap (JenOrder[MinI], JenOrder[I], )

End Function

Function BubbleSort ( )

Begin

Declare swapped as boolean. Set to true

Declare variable Index as integer

Declare variable counter as type integer

Declare passes as integer

Declare CCorder as an array holding Arraysize integer values

Constant ArraySize =15

Passes=0

Index=0

WHILE (Swapped = true) DO

Swapped=false

Passes=passes+1

FOR index=0 to <arraySize-passed DO

IF CCorder[counter] < CCorder[counter+1] THEN

Temp=CCorder[counter]

CCorder[counter]=CCorder[counter+1]

CCorder[counter+1]=temp

Swapped=true

Display CCorder[i]

Endif

Endfor

End function

Function FoodSelection

Declare variables FoodChoice as Char

Set Constant JJUsize=10

Set Constant NSSBsize=20

Set Constant CCsize=15

If choice=”1” THEN

Populate ()

BreadCompList ( CustomerID)

BinarySearch (BCList[i], CustomerID[i])

If FoodChoice=”2” THEN

Populate( )

SelectionSort ( JenOrder[i],)

Selectionsort(JerOrder[i])

If FoodChoice=”3” THEN

PopulateArray(CCSize[i], Customer ID,CCorder )

BubbleSort ()

Else display “Invalid request”

************ AT THIS POINT I AM FINNISHED DECLARING MY VARIABLES*******

Function FoodSelection

Declare variables FoodChoice as Char

Set Constant JJUsize=10

Set Constant NSSBsize=20

Set Constant CCsize=15

If choice=”1” THEN

Populate ()

BreadCompList ( CustomerID)

BinarySearch (BCList[i], CustomerID[i])

If FoodChoice=”2” THEN

Populate( )

SelectionSort ( JenOrder[i],)

Selectionsort(JerOrder[i])

If FoodChoice=”3” THEN

PopulateArray(CCSize[i], Customer ID,CCorder )

BubbleSort ()

Else display “Invalid request”

____________________

My Problem is that my Teacher says that functions are only supposed to do one particular task each. But myn doesn't work like that -.-

Also another Clue ihave that makes me think i'm doing it wrong is that the istructions says " You must use at least two functions" But dont i have to use functions for everything?

HELP HELP HELP

I have read my notes, watched youtube vids and used my books but i still feel like i have a gap in my Knowledge somehow.

Here are my instructions

HERE ARE MY INSTRUCTIONS

What started out as a little “baking on the side” for Della has now become a full-time venture. She has recently opened Della’s Delectable Delights, a bakery and café selling pastries and other baked goods. However, she needs some assistance in managing the numerous orders she gets on a daily basis.

She wishes you to design a system which will help her to manage orders for her specialty items: Not-so-salt Bread, Jam Jump-ups and Coconut Cravers.

At the end of each day, Della wants to enter the orders (in no particular sequence) which have come in for the following day. Each of the three specialty items need to be dealt with differently and your system must be able to handle the requirements.

1) Not-so-salt Bread: Often, customers can’t wait to get their hands on their Not-so-salt Bread and call to enquire if their order would be ready for early collection. Therefore, once Brenda has completed a Not-so-salt Bread order, she places the customer ID on the Bread Completion List. Della is then able to search the list for the ID of the enquiring customer. You may assume there are a maximum of 20 separate customer orders for Not-so-salt Bread; Binary Search is required – assume list is in descending order.

2) Jam Jump-ups: Janine and Jerry handle all of the orders for Jam Jump-ups. Any orders which are over 25 are handled by Janine; all others are handled by Jerry. The system will be required to separate and allocate the orders to the appropriate baker. Once all of the orders have been allocated, the sorted list for each baker should be displayed along with a total number of Jam Jump-ups for each baker. You may assume there are a maximum of 10 separate customer orders for Jam Jump-ups; Selection Sort is required – assume ascending order.

3) Coconut Cravers: Colin and Connie are the most competitive Coconut Craver creators you will ever come across. There is always a challenge to see who will make the most Coconut Cravers and be Coconut Craver Champion at the end of each day. Therefore, the list of orders should be printed for them with the largest first so that whoever completes their current order first, may pull the next largest. You may assume there are a maximum of 15 separate customer orders for Coconut Cravers; Bubble Sort is required.

INSTRUCTIONS

1. Create a single algorithm to handle the requirements.

2. You must define and use at least two functions.

_____

Okay so basically, I have to follow the instructions, but I CANNOT USE GLOBAL VARIABLES. So doesn't that mean that my ENTIRE program will have to be a complilation of functions?

Here is my Psuedocode (Part of it)

___

Begin Algorithm

¬Function PopulateArray ()

Declare variable I as integer

Declare constant NSSbSize=20

Declare Array CustomerID to hold 20 Integer Values

Declare Integer Array NSSBorder of size NSSbSize

I=0

For I=0 to NSSbSize-1

Display “Please enter the ID of the Customer”

Read CustomerID[i]

Display “Please enter Order.”

Input NSSBOrder[i]

End Function

Function BreadCompList (CustomerID )

Display “Is this Customers [CustomerID[i]] order complete? (Yes/No) ”

Input Choice

Declare variable Choice as string

If Choice=”yes” THEN

CustomerID[i] =BCList[ i]

EndIf

End Function

// Defining binary search function

Function BinarySearch (BCList[i], CustomerID[i],NSSBsize)

BEGIN

Declare min, max, mid, search key as Integer

“Please enter the ID of the Customer whose order you are checking on.”

Input CustomerID

Searchkey:=0

Min:=0

Max:=NSSBsize-1

WHILE max >= min DO

Mid:=(min+max) div2

IF BCList[mid] = searchkeyTHEN

Display “ This Order is ready.”

Stop?

ELSE IF searchKey < BCList [mid] THEN

Max:=mid-1

Else

Min:=Mid+1

EndIf

Endwhile

Display “This order is not ready.”

Endfucntion

//Defining swap function

Function Swap ( JenOrder[i], JenOrder[J] )

Begin

Temp= JenOrder[i]

JenOrder[i]=JenOrder[minI]

JenOrder[minI]=temp

EndFunction

¬¬¬¬¬ // Define Selection sort function

Function SelectionSort (JJUsize, JenOrder[i] bring in a counter?)

Begin

Declare MinI, J as data type integer

MinI=0

J=0

FOR i=0 to JJUSize-1 DO

FOR J=i + 1 to arraySize-1 DO

IF (JenOrder[j] < JenOrder[MinI]

MinI=J

IF (minIndex !=i) THEN

Swap (JenOrder[MinI], JenOrder[I], )

End Function

Function BubbleSort ( )

Begin

Declare swapped as boolean. Set to true

Declare variable Index as integer

Declare variable counter as type integer

Declare passes as integer

Declare CCorder as an array holding Arraysize integer values

Constant ArraySize =15

Passes=0

Index=0

WHILE (Swapped = true) DO

Swapped=false

Passes=passes+1

FOR index=0 to <arraySize-passed DO

IF CCorder[counter] < CCorder[counter+1] THEN

Temp=CCorder[counter]

CCorder[counter]=CCorder[counter+1]

CCorder[counter+1]=temp

Swapped=true

Display CCorder[i]

Endif

Endfor

End function

Function FoodSelection

Declare variables FoodChoice as Char

Set Constant JJUsize=10

Set Constant NSSBsize=20

Set Constant CCsize=15

If choice=”1” THEN

Populate ()

BreadCompList ( CustomerID)

BinarySearch (BCList[i], CustomerID[i])

If FoodChoice=”2” THEN

Populate( )

SelectionSort ( JenOrder[i],)

Selectionsort(JerOrder[i])

If FoodChoice=”3” THEN

PopulateArray(CCSize[i], Customer ID,CCorder )

BubbleSort ()

Else display “Invalid request”

************ AT THIS POINT I AM FINNISHED DECLARING MY VARIABLES*******

Function FoodSelection

Declare variables FoodChoice as Char

Set Constant JJUsize=10

Set Constant NSSBsize=20

Set Constant CCsize=15

If choice=”1” THEN

Populate ()

BreadCompList ( CustomerID)

BinarySearch (BCList[i], CustomerID[i])

If FoodChoice=”2” THEN

Populate( )

SelectionSort ( JenOrder[i],)

Selectionsort(JerOrder[i])

If FoodChoice=”3” THEN

PopulateArray(CCSize[i], Customer ID,CCorder )

BubbleSort ()

Else display “Invalid request”

____________________

My Problem is that my Teacher says that functions are only supposed to do one particular task each. But myn doesn't work like that -.-

Also another Clue ihave that makes me think i'm doing it wrong is that the istructions says " You must use at least two functions" But dont i have to use functions for everything?

HELP HELP HELP