Westonci.ca offers fast, accurate answers to your questions. Join our community and get the insights you need now. Explore our Q&A platform to find in-depth answers from a wide range of experts in different fields. Get precise and detailed answers to your questions from a knowledgeable community of experts on our Q&A platform.

Write a C# program that prints the number of quarters, dimes, nickels, and pennies that a customer should get back as change. Declare and initialize all memory locations as integers. On output, show the original change amount as a monetary amount, with two positions to the right of the decimal. Run your program once by performing a compile-time initialization using 92 cents for the value to be converted.

Sagot :

Following are the code of C# to prints the number of quarters, dimes, nickels, and pennies

Program Explanation:

  • Declaration of the namespace.
  • Made a class named "Class1".
  • Declared the methods as well as the attributes.
  • Declared the main method.
  • Wrote the statements according to the given query.

Program:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

namespace Project1

{

   class Class1      

   {

       static void Main(string[] args)

       {

           int change = 0;

           int quart, dim, nic, pen;

           Console.WriteLine("enter amount of cents (less than 99)");

           change = int.Parse(Console.ReadLine());

           quart = change / 25; //calculate the remainder              

           int p = change % 25;

           dim = (p / 10);

           int a = p % 10;

           // Nickles

           nic = a / 5;

           int c = a % 5;

           pen = c;

           Console.Write("There are {0} quarters.\n", quart);

           Console.Write("There are {0} dimes.\n", dim);

           Console.Write("There are {0} nickels.\n", nic);

           Console.Write("There are {0} pennies.\n", pen);

           Console.ReadLine();

       }

   }

}

Output:

Please find the attachment of the output.

Learn more about C# here:

https://brainly.com/question/5023004

View image Cricetus