示例#1
0
    public static int Main(string[] args)
    {
        InputWrapper iw = new InputWrapper();
        double       amount;    // annual deposit amount
        double       rate;      // interest rate
        int          years;     // number of years
        double       total;     // total accumulation

        amount = iw.getDouble("amount: ");
        rate   = iw.getDouble("rate: ");
        years  = iw.getInt("years: ");
        total  = amount * (Math.Pow(1 + rate, years) - 1) / rate;
        long total_in_cents = (long)Math.Round(total * 100);

        total = total_in_cents / 100.0;
        WriteLine("total = {0}", total);
        return(0);
    }
示例#2
0
    public static void Main(string[] args)
    {
        InputWrapper iw     = new InputWrapper();
        double       radius = iw.getDouble("radius: ");
        double       area   = 3.1416 * radius * radius;

        Console.WriteLine("Using, 3.1416, area = " + area);
        area = Math.PI * radius * radius;
        Console.WriteLine("Using, Math.PI, area = " + area);
    }
示例#3
0
    public static int Main(string[] args)
    {
        InputWrapper iw     = new InputWrapper();
        decimal      amount = iw.getDecimal("Amount of loan: "); // amount of loan
        double       rate   = iw.getDouble("Interest rate");     // interest rate
        int          months = iw.getInt("Number of periods");    // number of periods
        // Prompt for amount of loan, interest rate, and months
        // Calculate monthly payment using payment() method
        // Display this payment
        decimal monthlyPayment = payment(amount, rate, months);

        Console.WriteLine("Your monthly payment is {0}", monthlyPayment);
        return(0);
    }
示例#4
0
    public static int Main(string[] args)
    {
        InputWrapper iw = new InputWrapper();     // get an input reader (read from stdin)
        int          i  = iw.getInt("enter integer: ");

        Console.WriteLine("i = {0}", i);
        double d = iw.getDouble("enter double: ");

        Console.WriteLine("d = {0}", d);
        decimal dec = iw.getDecimal("enter decimal: ");

        Console.WriteLine("dec = {0}", dec);
        string s = iw.getString("enter string: ");

        Console.WriteLine("s = {0}", s);
        return(0);
    }
示例#5
0
    public static int Main(string[] args)
    {
        InputWrapper iw = new InputWrapper();
        decimal      amount;     // amount of loan
        double       rate;       // interest rate
        int          months;     // number of periods

        // Prompt for amount of loan, interest rate, and months
        amount = iw.getDecimal("amount: ");
        rate   = iw.getDouble("rate: ");
        months = iw.getInt("months: ");
        // Calculate monthly payment using payment() method
        decimal monthlyPayment = payment(amount, rate, months);

        // Display this payment
        Console.WriteLine("The monthly payment is: {0}", monthlyPayment);
        Console.ReadLine();
        return(0);
    }