Question

In: Computer Science

make a c++ program that calculates the amount left from a value of money of one...

make a c++ program that calculates the amount left from a value of money of one dollar bill or less in quarters, dimes, nickels, and pennies. The remaining value can be shown in cents knowing that in cents:

penny = 1

nickel = 5

dime = 10

quarter = 25

Solutions

Expert Solution

If you have any doubts, please give me comment...

#include <iostream>

using namespace std;

int main()

{

    int amount, quarters = 0, dimes = 0, nickels = 0, pennies = 0;

    cout << "Enter amount left from one dollars bill(in cents): ";

    cin >> amount;

    if (amount > 99)

        cout << "please enter an amount less than one dollar" << endl;

    else

    {

        quarters = amount / 25;

        amount %= 25;

        dimes = amount / 10;

        amount %= 10;

        nickels = amount / 5;

        amount %= 5;

        pennies = amount;

        cout << "quarters: " << quarters << endl;

        cout << "dimes: " << dimes << endl;

        cout << "nickels: " << nickels << endl;

        cout << "pennies: " << pennies << endl;

    }

    return 0;

}


Related Solutions

Design a c++ program that calculates the amount of money a person would earn over a...
Design a c++ program that calculates the amount of money a person would earn over a period of time if his salary is one penny the first day, two pennies second day, and continues to double each day. The program should ask the user for the number of days. Display a table showing what the salary was for each day, and then show total pay at the end of the period. the output should be displayed in a dollar amount,...
Your task is to write a program in C or C++ that calculates the total amount...
Your task is to write a program in C or C++ that calculates the total amount of money a person has made over the last year. Your program will prompt the user for dollar amounts showing how much the user has made per job. Some users will have had more than one job, make sure your program allows for this. The program will print out the total made (all jobs) and will print out the federal and state taxes based...
a.Create the logic for a program using pseudocode that calculates and displays the amount of money...
a.Create the logic for a program using pseudocode that calculates and displays the amount of money you would have if you invested $5000 at 2 percent simple interest for one year. Create a separate method to do the calculation and return the result to be displayed. b.Modify the program in Exercise 2a so that the main program prompts the user for the amount of money and passes it to the interest-calculating method. c.Modify the program in Exercise 2b so that...
1. Write the C++ code for a program that calculates how many days are left until...
1. Write the C++ code for a program that calculates how many days are left until Halloween, when given as an input how many weeks are left until Halloween. Use variables named weeks and days. ------------ 2. What header file must be included - To perform mathematical functions like sqrt? - To use cin and cout? - To use stream manipulators like setprecision? -------------------- 3. What value will be stored in the variable t after each of the following statements...
For C++ Download the attached program template. The programs calculates the amount of profit or loss...
For C++ Download the attached program template. The programs calculates the amount of profit or loss from a stock transaction. Using the values initialized by the program, calculate and print out the following results: "Total paid for stock" "Purchase commission " "Total received for stock" "Sales commission" "Amount of profit or loss" Use the following formulas: Total_paid = (total purchase price) + purchase_commission; Total_received = (total sales price) - sales_commission; profit = Total_received - Total_paid /* * COSC 1337 Programming...
Write a C program that calculates the average grade for a specified number of students from...
Write a C program that calculates the average grade for a specified number of students from each student's test1 and test2 grades. The program must first ask the user how many students there are. Then, for each student, the program will ask the user for the test1 grade (grade #1) and test2 grade (grade #2). The program should be able to handle up to 100 students, each with 2 grades (test1 and test2). Use a two-dimensional float array to store...
Write a C program that calculates the average grade for a specified number of students from...
Write a C program that calculates the average grade for a specified number of students from each student's termtest and final grade. The program must first ask the user how many students there are. Then, for each student, the program will ask the user for the termtest grade (grade #1) and final grade (grade #2). The program should be able to handle up to 100 students, each with 2 grades (termtest and final). Use a two dimensional float array to...
Make a program that calculates the total of a retail sale. The program should ask the...
Make a program that calculates the total of a retail sale. The program should ask the user for the following: the retail price of the item being purchased and the sales tax rate. Once the information has been entered, the program should calculate and display the following: the sales tax for the purchase and the total sale.
In the space provided below write a C program that computes the total amount of money...
In the space provided below write a C program that computes the total amount of money you have stored in your piggy bank. Your program does this by asking you for number of pennies, nickels, dimes, and quarters in the piggy bank and then displays how much money in total is in the piggy bank.
In C Program #include Create a C program that calculates the gross and net pay given...
In C Program #include Create a C program that calculates the gross and net pay given a user-specified number of hours worked, at minimum wage. The program should compile without any errors or warnings (e.g., syntax errors) The program should not contain logical errors such as subtracting values when you meant to add (e.g., logical errors) The program should not crash when running (e.g., runtime errors) When you run the program, the output should look like this: Hours per Week:...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT