For your birthday, you received $10 gift certificate for an online music store. You can buy songs until your money is gone. Write a C++ program that allows a user to repeatedly buy songs from your online music store. The initial balance is $10. For simplicity, we will just input from the user the cost of the song (usually $0.99, $1.99 or $2.99) and ignore the song name and artist name. Exit the loop when the user doesn't have enough money to buy more songs and display the remaining balance. A sample output looks like the following:
Enter the cost of the song, ($0.99, $1.99, or $2.99): 0.99
Your remining balance is: 9.01.
Enter the cost of the song, ($0.99, $1.99, or $2.99): 1.99
Your remining balance is: 7.02.
Enter the cost of the song, ($0.99, $1.99, or $2.99): 0.99
Your remining balance is: 6.03.
Enter the cost of the song, ($0.99, $1.99, or $2.99): 2.99
Your remining balance is: 3.04.
Enter the cost of the song, ($0.99, $1.99, or $2.99): 2.99
Your remining balance is: 0.05.
Sorry, balance is $0.05. You can't buy more songs.
This is what I have so far. I don't understand how to do this fully.
#include <iostream>
using namespace std;
int main()
{
int cost;
int sum;
int count;
sum = 10;
count = 0;
cost = 1;
do
{
cout << "Enter the cost of the song, ($0.99, $1.99, or $2.99): " ;
cin >> cost;
sum = sum - cost;
cout << "Your remaining balance is: " ;
cout << sum << endl;
count++;
}
while (count > 0.99);