# Logic and Desgin Help



## cynthia318 (Jan 21, 2012)

​Need some help getting stated here have try every way.

Your algorithm will keep track of a customer’s purchases at the local fireworks stand. Customers will not know exactly how many items they will purchase, so using a FOR loop on this lab is not allowed. Let’s keep the rules simple. 
1) Accept the dollar value of each item purchased from the user until the user is finished. 
2) When purchases are complete, enter a sentinel value of -1. (Make certain you do not include the -1 sentinel value in your total). 
3) Keep track of the total dollar amount of all fireworks purchased. 
4) Keep a tally of the number of items purchased. 
5) If more than 20 items were purchased, give your customer a 10% discount on their total purchases. 
6) Once purchases are complete, display the total number of items purchased, the average price of the items, the total of all fireworks purchased, any discount if applicable & the total of all fireworks purchased minus the discount.


----------



## Laxer (Dec 28, 2010)

Would a while loop work?

while(sentinel_value!=1){
Select options and keep track of everything here
total=total+XXX
items++
}

I don't see how a for loop would even be useful here unless you had an array of input...


----------



## cynthia318 (Jan 21, 2012)

I have to use an array for this one


----------



## Laxer (Dec 28, 2010)

What does the input array look like?


----------



## AceInfinity (Jan 21, 2012)

Does something like this work as well?

while(sentinel_value!=1){
Select options and keep track of everything here
total+=XXX
items++
}


----------



## Laxer (Dec 28, 2010)

AceInfinity said:


> Does something like this work as well?
> 
> while(sentinel_value!=1){
> Select options and keep track of everything here
> ...


Would depend on the language....

In PHP string concatenation is .= not +=.... :dance:


----------



## AceInfinity (Jan 21, 2012)

Laxer said:


> Would depend on the language....
> 
> In PHP string concatenation is .= not +=.... :dance:


Yeah  I've seen that been done in a few PHP scripts. I have little knowledge on PHP, so I learn from the others that do know PHP on the forums I frequent.

Lots of compiled programming languages have += including the .NET family, batch, perl, etc... So that's what i've always been used to. :dance:

~Ace


----------

