Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a Console application called Money and make sure that the project name is

ID: 3868982 • Letter: C

Question

Create a Console application called Money and make sure that the project name is Money, and that your class name is Money and that the program file name is Money.cs. Your program will determines the total values of coins in a jar and print out the total in dollars and cents. Your program will prompt the user to enter the number of coins (quarters, dimes, nickels, and pennies). Then it will print out the total amount of money in the jar as dollars and cents. Example: Number of quarters: 1284 Number of dimes: 3 Number of nickels: 0 Number of pennies: 4 Total = 321 Dollars and 34 Cents.

Explanation / Answer

Money.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
/*Namespace decalaration */

namespace Money
{
    class Money
    {
        static void Main(string[] args)
        {
            /*data types declaration*/

            int quart, dim, nic, pen;
            double dollars, cents;
            string s;
          
            /* Write & Read from console*/

            Console.WriteLine("Number of quarters:");
            s = Console.ReadLine();
            quart = int.Parse(s);
          
            Console.WriteLine("Number of dimes:");
            s = Console.ReadLine();
            dim = int.Parse(s);
          
            Console.WriteLine("Number of nickels:");
            s = Console.ReadLine();
            nic = int.Parse(s);
          
            Console.WriteLine("Number of pennies:");
            s = Console.ReadLine();
            pen = int.Parse(s);
          
            /* conversion formula*/

            dollars=(pen*.01)+(nic*.05)+(dim*.10)+(quart*0.25);
            double dollar2=((dollars*100)-((dollars*100)%100))/100;
            cents=(dollars*100);
            cents=cents%100;
            Console.Write("Total = {0:F} dollars and ", dollar2);
            Console.Write(cents);
            Console.Write(" cents.");
        }

    }

}

Output :-