/* Program for a change-counting game that gets the user to enter the number of coins required to make exactly one dollar. The program will ask the user to enter the number of pennies, nickels, dimes and quarters. If the total value of the coins entered is equal to one dollar, the program will congratulate the user for winning the game. Otherwise, the program will display a message indicating whether the amount entered was more than or less than one dollar. */ #include<iostream> using namespace std; int main() { int pennies, nickels, dimes, quarters; float total; //For getting Input cout << "Enter :\n"; cout << "Pennies?\t"; cin >> pennies; cout << "Nickels?\t"; cin >> nickels; cout << "Dimes?\t"; cin >> dimes; cout << "Quarters?\t"; cin >> quarters; //For calculating sum of entered currency total = pennies*.01 + nickels*.05 + dimes*.1 + quarters*.25; cout << endl; //For Formatting Output for (int i = 0; i < 80; i++) cout << "=="; //For checking total and display suitable message if (total == 1) cout << "\n\t\t\t\tCongragulations!!!!\nYOU WON THE GAME...........\n"; else if (total < 1) cout << "\nSorry you lost....Entered amount is less than 1$\n"; else cout << "\nSorry you lost....Entered amount is more than 1$\n"; return 0; }
No comments:
Post a Comment