Compute the regular payments for a loan : decimal « Data Types « C# / C Sharp

Home
C# / C Sharp
1.2D Graphics
2.Class Interface
3.Collections Data Structure
4.Components
5.Data Types
6.Database ADO.net
7.Design Patterns
8.Development Class
9.Event
10.File Stream
11.Generics
12.GUI Windows Form
13.Language Basics
14.LINQ
15.Network
16.Office
17.Reflection
18.Regular Expressions
19.Security
20.Services Event
21.Thread
22.Web Services
23.Windows
24.Windows Presentation Foundation
25.XML
26.XML LINQ
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source
C# / C Sharp » Data Types » decimalScreenshots 
Compute the regular payments for a loan
Compute the regular payments for a loan
 
/*
C# A Beginner's Guide
By Schildt

Publisher: Osborne McGraw-Hill
ISBN: 0072133295
*/
 /* 
   Project 2-3 
 
   Compute the regular payments for a loan. 
 
   Call this file RegPay.cs 
*/ 
 
using System; 
 
public class RegPay {    
  public static void Main() {    
    decimal Principal;    // original principal 
    decimal IntRate;      // interest rate as a decimal, such as 0.075 
    decimal PayPerYear;   // number of payments per year 
    decimal NumYears;     // number of years 
    decimal Payment;      // the regular payment 
    decimal numer, denom; // temporary work variables 
    double b, e;          // base and exponent for call to Pow() 
 
    Principal = 10000.00m; 
    IntRate = 0.075m; 
    PayPerYear = 12.0m; 
    NumYears = 5.0m; 
 
    numer = IntRate * Principal / PayPerYear; 
  
    e = (double-(PayPerYear * NumYears)
    b = (double) (IntRate / PayPerYear1
 
    denom = (decimalMath.Pow(b, e)
     
    Payment = numer / denom; 
 
    Console.WriteLine("Payment is {0:C}", Payment)
  }    
}


           
         
  
Related examples in the same category
1.Using Decimals
2.Use the decimal type to compute a discount. Use the decimal type to compute a discount.
3.Use the decimal type to compute the future value of an investmentUse the decimal type to compute the future value     of an investment
4.Compute the initial investment needed to attain a known future value given Compute the initial investment needed to attain     a known future value given
5.Manually create a decimal numberManually create a decimal number
6.decimal property
7.explicit conversions from decimal to int
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.