using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace test
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Please enter the Principal: ");
int principal = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Please enter the rate: ");
int rate = Convert.ToInt32(Console.ReadLine());
int a = rate / 100;
int b = a * principal;
int x = b + principal;
int[] sample = {};
Console.WriteLine("How long do you want the loop to run: ");
int loop = Convert.ToInt32(Console.ReadLine());
// StringBuilder sb = new StringBuilder();
for (int i = 0; i <= loop; i++)
{
sample[x] = x;
// sb.AppendLine(x.ToString());
b = a * x;
x = b + x;
}
Console.WriteLine(sample);
}
}
}
Hi, I just started learning C# and the topic that my teacher discussed today was arrays. So I decided to create a simple Interest Calculator, but it's giving me
"System.IndexOutOfRangeException: Index was outside the bounds of the array."