Esempio n. 1
0
        private void Intrest_Calculate_Button_Click(object sender, EventArgs e)
        {
            bool convertRateToMonths = false;
            bool convertTimeToMonths = false;

            if (InvestInterestYearsMonths.Text.Equals("Months"))
            {
                convertRateToMonths = true;
            }

            invest = new Invest(presentValue, payment, r, t, convertRateToMonths, convertTimeToMonths);

            Calculation_label.Text = "Your balance will be " + invest.FutureValue(presentValue, payment, r, t).ToString("c2");
        }
Esempio n. 2
0
        private void HowMuchButton_Click(object sender, EventArgs e)
        {
            bool convertRateToMonths = false;
            bool convertTimeToMonths = false;

            if (InvestInterestYearsMonths.Text.Equals("Per Month"))
            {
                convertRateToMonths = true;
            }

            invest = new Invest(desiredAmount, presentValue, payment, r, t, convertRateToMonths, convertTimeToMonths);

            HowMuchLabel.Text = "You need to save " + invest.HowMuchToSave(desiredAmount, presentValue, r, t).ToString("c2") + (convertTimeToMonths ? " a month.": " a year.");
        }
Esempio n. 3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Create your application here
            SetContentView(Resource.Layout.activity_invest_how_much_to_save);

            EditText desiredAmountText  = FindViewById <EditText>(Resource.Id.desired_amount_editText);
            EditText currentSavingsText = FindViewById <EditText>(Resource.Id.present_value_desired_amount_editText);
            EditText annualRateText     = FindViewById <EditText>(Resource.Id.rate_desired_amount_editText);
            EditText timeText           = FindViewById <EditText>(Resource.Id.time_desired_amount_editText);

            RadioButton yearButton      = FindViewById <RadioButton>(Resource.Id.year_desired_amount_radioButton);
            RadioButton monthButton     = FindViewById <RadioButton>(Resource.Id.month_desired_amount_radioButton);
            Button      calculateButton = FindViewById <Button>(Resource.Id.invest_desired_amount_calculate_Button);
            TextView    resultTextView  = FindViewById <TextView>(Resource.Id.result_desired_amount_textView);

            yearButton.Click += (sender, e) =>
            {
                annualRateText.Hint = Resources.GetString(Resource.String.timeYears);
                changeRateToMonths  = false;
            };

            monthButton.Click += (sender, e) =>
            {
                changeRateToMonths  = true;
                annualRateText.Hint = Resources.GetString(Resource.String.timeMonths);
            };

            calculateButton.Click += (sender, e) =>
            {
                double.TryParse(desiredAmountText.Text, out desiredAmount);
                double.TryParse(currentSavingsText.Text, out presentValue);
                double.TryParse(annualRateText.Text, out rate);
                int.TryParse(timeText.Text, out time);

                invest = new Invest(0, 0, 0, 0, changeRateToMonths, false);

                resultTextView.Text = invest.HowMuchToSave(desiredAmount, presentValue, rate, time).ToString("c2");
            };
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            //Set our view from the invest layout resource
            SetContentView(Resource.Layout.activity_invest);

            // Create your application here
            Button   calculationButton = FindViewById <Button>(Resource.Id.invest_calculate_Button);
            EditText presentValueInput = FindViewById <EditText>(Resource.Id.present_value_editText);
            EditText periodInput       = FindViewById <EditText>(Resource.Id.period_editText);
            EditText rateInput         = FindViewById <EditText>(Resource.Id.rate_editText);
            EditText timeInput         = FindViewById <EditText>(Resource.Id.time_editText);
            TextView resultTextView    = FindViewById <TextView>(Resource.Id.result_textView);

            RadioButton yearButton  = FindViewById <RadioButton>(Resource.Id.year_radioButton);
            RadioButton monthButton = FindViewById <RadioButton>(Resource.Id.month_radioButton);

            yearButton.Click += (sender, e) =>
            {
                timeInput.Hint     = Resources.GetString(Resource.String.timeYears);
                changeRateToMonths = false;
            };

            monthButton.Click += (sender, e) =>
            {
                changeRateToMonths = true;
                timeInput.Hint     = Resources.GetString(Resource.String.timeMonths);
            };

            //presentValueInput.OnFocusChangeListener = FormatTextMoney(presentValueInput, presentValue);

            //presentValueInput.FocusChange += (sender, e) =>
            //{
            //    double temp;

            //    if (Double.TryParse(presentValueInput.Text, out temp))
            //        presentValue = temp;
            //    //presentValueInput.Text = temp.ToString("c2");
            //};
            //periodInput.FocusChange += (sender, e) =>
            //{
            //    double temp;

            //    if (Double.TryParse(periodInput.Text, out temp))
            //        period = temp;
            //    //periodInput.Text = temp.ToString("c2");
            //};
            //rateInput.FocusChange += (sender, e) =>
            //{
            //    double temp = 0;
            //    if (Double.TryParse(rateInput.Text, out temp))
            //        rate = temp;
            //    //rateInput.Text = temp + "%";
            //};
            //timeInput.FocusChange += (sender, e) =>
            //{
            //    int.TryParse(timeInput.Text, out time);
            //};

            calculationButton.Click += (sender, e) =>
            {
                Double.TryParse(presentValueInput.Text, out presentValue);
                Double.TryParse(periodInput.Text, out period);
                Double.TryParse(rateInput.Text, out rate);
                int.TryParse(timeInput.Text, out time);

                if (presentValueInput.Text == null || periodInput.Text == null || rateInput.Text == null || timeInput.Text == null)
                {
                    resultTextView.SetTextColor(Android.Graphics.Color.Red);
                    resultTextView.Text = "Please Input proper values.";
                }
                else
                {
                    invest = new Invest(presentValue, period, rate, time, changeRateToMonths, false);

                    resultTextView.SetTextColor(Android.Graphics.Color.Green);
                    resultTextView.Text = invest.FutureValue(presentValue, period, rate, time).ToString("c2");
                }
            };
        }