Day 3.0 Exercise 12 Prompting people for Number.

Here’s my work.
Here’s the link to exercise 12.

Ex12 Code
Ex12 Code with extra on how to prompt for money 😀 $$
Ex12 Shell
Ex12 output

Study Drill

1. Try out the .to_f operation. What does .to_f do?
.to_f converts string into float data type.

2. To play with .to_f more, make a small script that asks for some money and gives back 10% of it. If I give your script 103.4 (dollars), your script gives me back 10.34 in change.
Done. I used 20% and used 2 different ways to give the correct decimal places, however .round does not always return the desired point if the trailing numbers are zeros. I thought there were a way to convert to currency. So ‘%.2f’ % is still a better way to do it.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s