Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Turing Help!!!!!!!!
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
spiderman




PostPosted: Mon Dec 12, 2005 5:09 pm   Post subject: Turing Help!!!!!!!!

In turing, how do you input a dollar ammount representing the fewest number of bills and codes? An example would be $25.53 dollars which is a twentie dollar bill, a five dollar bill, two quarters and three pennies. How would u do that on turing so that the user enters whatever dollar amount they want and answers it in fewest number of bills and coins. I know u have to use mod and div operators but my code just doesnt seem to work
Does anyone know the code for this?
Sponsor
Sponsor
Sponsor
sponsor
Mazer




PostPosted: Mon Dec 12, 2005 5:45 pm   Post subject: (No subject)

Firstly, you may want to show us your code so that we can help you fix any mistakes you've made.

Second, you should have posted this in [Turing Help] (moved)

Third, it's best not to use descriptions like "Turing Help!!!!!!!!" as that is more likely to make us hate you than it is to make us want to help you.
foo fighter




PostPosted: Mon Dec 12, 2005 5:52 pm   Post subject: (No subject)

[mod:dffcccb924="Cervantes"]
Personal conversations may be carried out via Private Messages, please and thank you. Click the "PM" button under a user's name to PM him. Or her.[/mod:dffcccb924]
Albrecd




PostPosted: Mon Dec 12, 2005 6:15 pm   Post subject: (No subject)

Asok Said:
Quote:
any thread with the topic title is general such as "I need help" "help me please" "Help fast ASAP" will be deleted and you will not recieve help.


Anyway... You could devide the total by the highest value that can be held by a bill (round down), then multiply the quocient by the value of that bill, then subtract the product from the inputted value, then do the same with the other bill and coin values in decending order.

Ex:
code:

var input, NumBill50, NumBill50Round : real
var NumBills : int
Const DOLLARS50 := 50

NumBill50 := input / DOLLARS50     %Devide the input by 50 for $50 bill
NumBill50Round := input div DOLLARS50 %Same as ^ with rounding
if NumBill50 < NumBill50Round then           %If the unrounded quocient is
NumBill50Round -= 1                                %Lower than the rounded
end if                                                       %quocient, It has rounded up,
%Keep Track of the number of $50 bills...   %but it must round down so
                                                               %we subtract one.

input -= NumBill50Round

%Then do the same thing with the next bill or coin value and so on
%Yes, I am aware that $50 is not the highest Canadian bill value.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: