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

This is for Visual C# class, plz provide solutions could be working in Miscrosof

ID: 3903062 • Letter: T

Question

This is for Visual C# class, plz provide solutions could be working in Miscrosoft Visual Studio.

Create a change-counting game that gets the user to enter the number of coins required to make exactly one dollar. The program should let the user enter the number of pennies, nickels, dimes, and quarters. If the total value of the coins entered is equal to one dollar, the program should congratulate the user for winning the game. Otherwise, the program should display a message indicating whether the amount entered was more than or less than one dollar.

Explanation / Answer

using System;
using System.Collections.Generic;
using System.Linq;

class Coin_changer
{
public static void Main()
{
List<int> cns = new List<int>();
List<int> total = new List<int>() { 1, 5, 10, 25, 50 };
  
coin_change(cns, total, 0, 0, 51);
}

void coin_change(List<int> cns, List<int> total, int greatest, int total_amount, int outp)
{
  
if (total_amount == outp)
{
show(cns, total);
return;
}
  
if (total_amount > outp)
{
return;
}
  
foreach (int value in total)
{

if (value >= greatest)
{
List<int> copy = new List<int>(cns);
copy.Add(value);
coin_change(copy, total, value, total_amount + value, outp);
}
}
}

static void show(List<int> cns, List<int> total)
{
foreach (int amount in total)
{
int count = cns.Count(value => value == amount);
Console.WriteLine("{0}: {1}",
amount,
count);
}
Console.WriteLine();
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote