Help needed

0 Georgia Root · September 8, 2014
Please assist me in how I would write this program, I am lost at doing decimals


 write a utility that converts dollars to coins. It is a simple program that must have the following:
Multiple outputs to the screen
At least one input
The use of integers and strings
Looking or repetition with Do..While, If..Else
Must have some output text to show correct value of coins that would be converted from the dollars.
Code must include comments explaining your reason for the code section or what the code is doing
Code must compile
Whole dollars only. If value is less than 1 or 0, the program should break or exit. 


int main() {

double x;
int y;
cout << " enter the amount: " <<endl;
cin >> x ;
y=x*100;
cout << " You will need " << Y/25 << " quarters " ;
y=y%25;
cout << " , " << y/10 << "dimes " ;
y=y%10;
cout << " , " << y/5 << " nickels " ;
y=y%5;
cout << " , " << y/1 << " pennies " ;
return 0;
}

Post a Reply

Replies

Oldest  Newest  Rating
0 Georgia Root · September 9, 2014
int main() {

double x;
int y;
cout << " enter the amount: " <<endl;
cin >> x ;
y=x*100;
cout << " You will need " << Y/25 << " quarters " ;
y=y%25;
cout << " , " << y/10 << "dimes " ;
y=y%10;
cout << " , " << y/5 << " nickels " ;
y=y%5;
cout << " , " << y/1 << " pennies " ;
return 0;
}
0 ragmar thomas · September 9, 2014
#include <iostream>

using namespace std;

int main() {
    int choice;

    cout << "to enter the amount of dollar -1" << endl;
    cout << "to exit exchange -2" << endl;
    cin >> choice;

    do{
            cout << "1$ is:- 0-dimes\n\t0-nickel\n\t0-pennies\n" << endl;
    break;

    }while(choice != 2);

you can insert this kind of statement in your main function with couple of if  - else statements 
like if (the user input more than 1$)
            your code 
else
        if (the user input less than 1$)
             //you should have more than 1$ to have changes

these might help you good luck.
  • 1

C++

107,044 followers
About

Used in many types of software including music players, video games, and many large scale applications.

Links
Moderators
Bucky Roberts Administrator