A customer needs a specific amount of paper. The charges on the paper are RM0.10 for single sheets, RM0.07 for amounts in multiples of 100 sheets, RM0.05 in multiples of 500 sheets, and RM0.03 in multiples of 1000 sheets.
Develop a solution to calculate the type and number of package(s) for the least amount of money the customer should buy. Given the minimum amount of sheets the customer needs. Your program is required continue process until 0 is enter as input for amount paper.
For example, if the customer needs 380 sheets, the amount she would pay when buying in multiples of 100 would be RM28.00. However if the customer bought 500 sheets the cost would be RM25.00. It would be cost effective for the customer to buy a package of 500 sheets.
the amount of paper must go up to at least 1000 sheets.I need a IPOchart,a flowchart,pseudocode and a comple c programme.But if there's a complete c programme is good enough.Help me out..
Need help in c programming..urgent.. pls help me?
get_sheets()
begin
do
print "Please enter a number of sheets between 1 and 1000"
print("Enter 0 to exit")
input lsheets
if lsheets %26lt; 0 or lsheets %26gt; 1000 then
print "Please enter a number between 0 and 1000"
endif
until lsheets %26gt;= 0 and lsheets %26lt;= 1000
return lsheets
end
main
begin
sheets = get_sheets()
while sheets %26lt;%26gt; 0
do
remainder = sheets
if remainder %26gt; 1000
then
thousands = int(remainder / 1000)
remainder = remainder - thousands * 1000
endif
if remainder %26gt; 500
then
fivehundreds = int(remainder / 500)
remainder = remainder - fivehundreds * 500
endif
if remainder %26gt; 500
then
hundreds = int(remainder / 100)
remainder = remainder - hundreds * 100
endif
price = thousands * 0.03 * 1000 +
fivehundreds * 0.05 * 500 +
hundreds * 0.07 * 100 +
remainder *0.10
print "The price for " sheets " sheets is " price " RM"
sheets = get_sheets()
done
end
primrose
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment