Return To CS 110 Home

Colour Theme   Font Size Options
 
   
   
   
Exercise 4

Event Loops: Online Music Store Exercise

For your birthday, you received a $10 gift certificate for an online music store. The cheapest song in the store costs $0.99. You can buy songs until you can't afford any more songs.

Instructions:

Here's the output from a sample run:
      
Enter the cost of a song: 0.99 Song purchased for $0.99! Enjoy!!! Your remaining balance is: 9.01 Enter the cost of a song: 1.99 Song purchased for $1.99! Enjoy!!! Your remaining balance is: 7.02 Enter the cost of a song: 2.99 Song purchased for $2.99! Enjoy!!! Your remaining balance is: 4.03 Enter the cost of a song: 1.99 Song purchased for $1.99! Enjoy!!! Your remaining balance is: 2.04 Enter the cost of a song: 2.99 Your choice is too expensive!!! Choose another one please! Your remaining balance is: 2.04 Enter the cost of a song: 0.99 Song purchased for $0.99! Enjoy!!! Your remaining balance is: 1.05 Enter the cost of a song: 1.99 Your choice is too expensive!!! Choose another one please! Your remaining balance is: 1.05 Enter the cost of a song: 0.99 Song purchased for $0.99! Enjoy!!! Your remaining balance is: 0.06 Your balance is $0.06. You cannot buy more songs. Come again!

When you are done: