Difference between revisions of "CSC111 Homework 2 2014"

From dftwiki3
Jump to: navigation, search
(Problem #1)
Line 16: Line 16:
  
 
  Please enter the amount of money you want to withdraw:  '''200.56'''
 
  Please enter the amount of money you want to withdraw:  '''200.56'''
 
+
 
   +------------------------------------+  
 
   +------------------------------------+  
   | Total amount withdrawn:  $ 200.56  |
+
  | Total amount withdrawn:  $ 200.56  |
   |                                    |
+
  |                                    |
   | 10  $20-bills                      |
+
  | 10  $20-bills                      |
   |  0  $10-bills                      |
+
  |  0  $10-bills                      |
   |  0  $5-bills                       |
+
  |  0  $5-bills                       |
   |  0  $1-bills                       |
+
  |  0  $1-bills                       |
   |-------------------                 |
+
  |-------------------                 |
   |  3  quarter(s)                     |
+
  |  3  quarter(s)                     |
   |  0  dime(s)                        |
+
  |  0  dime(s)                        |
   |  0  nickel(s)                      |
+
  |  0  nickel(s)                      |
   |  1  cent(s)                        |    
+
  |  1  cent(s)                        |    
 
   +------------------------------------+
 
   +------------------------------------+

Revision as of 19:50, 4 February 2014

--D. Thiebaut (talk) 19:41, 4 February 2014 (EST)


You must work in Pair-Programming mode on this homework.



Problem #1

  • Call your program hw2a.py
  • Using the same approach as took in Lab 2, write a Python program that asks the user for an amount of money (dollars) that can include cents, and outputs a breakdown of this amount into bills and coins.
  • This time, however, you must use the string-formatting output provided by the % operator, as introduced in Section 2.5.3 of the textbook. You cannot use the concatenation method we used to print your output. You must use the %-operator.

Here is an example of the output your program you emulate. Note the the line between the bills and the coins.

Please enter the amount of money you want to withdraw:  200.56

 +------------------------------------+ 
| Total amount withdrawn:  $ 200.56  |
|                                    |
| 10  $20-bills                      |
|  0  $10-bills                      |
|  0  $5-bills                       |
|  0  $1-bills                       |
|-------------------                 |
|  3  quarter(s)                     |
|  0  dime(s)                        |
|  0  nickel(s)                      |
|  1  cent(s)                        |    
 +------------------------------------+