Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace NBNFunding
- {
- class Program
- {
- struct Bond
- {
- private decimal value;
- public decimal Value
- {
- get
- {
- return value;
- }
- }
- private int created;
- public int Created
- {
- get
- {
- return created;
- }
- }
- public Bond(decimal value)
- {
- this.value = value;
- this.created = year;
- }
- }
- static List<Bond> Bonds = new List<Bond>();
- static int year = 2011;
- static void Main(string[] args)
- {
- //Time to Run Simulation
- int TimeFrame = 10 + year;
- //Initial Debt;
- Bonds.Add(new Bond(1000));
- for (; year <= TimeFrame; year++)
- {
- Console.WriteLine("Year: " + year);
- Console.WriteLine("Total Debt: ");
- Console.WriteLine(TotalDebt().ToString("C"));
- decimal interestOwed = TotalDebt() * 0.05m;
- Console.WriteLine("Interest: ");
- Console.WriteLine(interestOwed.ToString("C"));
- PayInterest(interestOwed);
- Console.WriteLine("");
- }
- Console.WriteLine();
- Console.WriteLine("After " + TimeFrame + " years, the following bonds have accured:");
- Console.WriteLine();
- Bonds.ForEach(bond =>
- {
- Console.WriteLine("Bond Value: "+bond.Value.ToString("C"));
- Console.WriteLine("Bond Created: " + bond.Created);
- Console.WriteLine();
- });
- Console.WriteLine();
- Console.WriteLine("Total Bonds: " + Bonds.Count());
- Console.WriteLine("Total Bond Value: " + TotalDebt().ToString("C"));
- Console.ReadKey();
- }
- static decimal TotalDebt()
- {
- decimal result = 0;
- Bonds.ForEach(bond => result += bond.Value);
- return result;
- }
- static void PayInterest(decimal interest)
- {
- Bonds.Add(new Bond(interest));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement