Saturday 28 September 2013

advice/help to finish this algorithn

advice/help to finish this algorithn

/
write a program that reads in a number between 5/95 and calculates change
**********************************************************************************
*************Author:Emma OostryckDate:20/9/13purpose:calculates and prints
out the
change
***************************************************************************
*********************/
Start _algorithm
int cents
int num
module main (void )
print "name" ()
cents = getnum()
end module main
module getnum () /*prompts the user for a number*/
int num
print"please enter a number between 5 and 95 "
scan "num"
if (num < 5 OR >95 ) THEN
print"this is an invalid number please try again "
else if (num != * 5 ) THEN
print"this is not a valid amount"
END IF
return (cents);
end module getnum
module calculatesum (num) /*calculates the change needed*/
int num,int change
change=num/50
num%=50
change=num/20
num%=20
change=num/10
change=num/5
num%=5
end module calculatesum
getnum
module printsum /*prints the change */
print"your total change is /intchange "
end module printsum end_algorithm

No comments:

Post a Comment