Create a program that can calculate the minimum payment that is needed to be paid to a credit card company based on the amount owed and a given interest rate. The amount owed will be the interest or $10, whichever is greater OR the amount owing if the amount owed is less than $10.
using System;
namespace Q264216
{
//Create a program that can calculate the minimum payment that is needed to be paid
//to a credit card company based on the amount owed and a given interest rate.
//The amount owed will be the interest or $10, whichever is greater
//OR the amount owing if the amount owed is less than $10.
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Enter amount owed on credit card");
var amtOwed = Convert.ToDecimal(Console.ReadLine());
Console.WriteLine("Enter an interest rate value as a percentage with the '%' character (this will be the APR)");
var interestRatePercent = Console.ReadLine();
Console.WriteLine("Assume 1 year term...\n");
var interestRateValue = Convert.ToDecimal(interestRatePercent.Remove(interestRatePercent.Length - 1, 1));
var interestRatePercentToDecimal = interestRateValue / 100;
if (amtOwed < 10)
{
Console.WriteLine($"Amount Owed is: ${amtOwed}");
}
else
{
//amount that is just interest: I = P*r
var i = amtOwed * interestRatePercentToDecimal;
//decide if interest balance is greater than 10, if so then finalAmount is interest balance, else $10
decimal finalAmount = i > 10.00m ? i : 10.00m;
Console.WriteLine($"Amount Owed is: ${finalAmount}");
}
}
}
}
Comments
Leave a comment