Beispiel #1
0
        public void ShowOutput()
        {
            Console.WriteLine("Your total amount is: ${0}", t.CalculateTotalAmount());
            Console.WriteLine("Your tip amount is: ${0}", t.CalculateTip());
            Console.WriteLine("The tax amount is: ${0}", t.CalculateTaxAmount());

            WriteTip gratuity = new WriteTip(@"C:\SCCC 2014-2015 WD Files\ITC110\Assignment9\writegratuity.txt");

            gratuity.AddToFile("The total amount of the meal is: " + t.MealAmount.ToString());
            gratuity.AddToFile("The recommended tip amount is: " + t.CalculateTip().ToString());
            gratuity.AddToFile("The grand total is: " + t.CalculateTotalAmount().ToString());
            gratuity.CloseFile();
        }
    protected void GetInfo()
    {
        Tip tip = new Tip();

        tip.MealAmount = double.Parse(MealTextBox.Text);

        if (OtherTextBox.Text == "")
        {
            foreach (ListItem item in TipPercentsRadioButtonList.Items)
            {
                tip.TipPercent = 0;
                if (item.Text.Equals("Ten Percent"))
                {
                    tip.TipPercent = .1;
                }
                else if (item.Text.Equals("Fifteen Percent"))
                {
                    tip.TipPercent = .15;
                }
                else if (item.Text.Equals("Twenty Percent"))
                {
                    tip.TipPercent = .20;
                }
            } //end of foreach
        }     //end of if(OtherTextBox)
        else
        {
            tip.TipPercent = double.Parse(OtherTextBox.Text);
        }

        ResultLabel.Text = "Amount:" + tip.MealAmount.ToString() + "<br/>" +
                           "Tip:" + tip.CalculateTip().ToString("$#,# # 0.00") + "<br/>" +
                           "Tax:" + tip.CalculateTax().ToString("$#,# # 0.00") + "<br/>" +
                           "Total:" + tip.CalculateTotal().ToString("$#,# # 0.00");
    }
 public TipCalculatorController()
 {
     display           = new Display();
     tip               = new Tip(display.Amount, display.Percent);
     display.TipAmount = tip.CalculateTip();
     display.Total     = tip.CalculateTotal();
     display.ShowTipAndTotal();
 }
Beispiel #4
0
        public void CalcTipTest()
        {
            t.BillAmount = 100;
            t.TipPercent = .20;
            double tipAmount = t.CalculateTip();

            Assert.AreEqual(tipAmount, 20);
        }
Beispiel #5
0
        private void performCalculation()
        {
            var selectedRadio = StackPanel.Children.OfType <RadioButton>().FirstOrDefault(r => r.IsChecked == true);

            if (selectedRadio != null)
            {
                tip.CalculateTip(billAmountTextBox.Text, double.Parse(selectedRadio.Tag.ToString()));
                amountToTipTextBlock.Text   = tip.TipAmount;
                amountToTotalTextBlock.Text = tip.TotalAmount;
            }
        }
    protected void GetInfo()
    {
        Tip tip = new Tip();

        tip.MealAmount = double.Parse(MealTextBox.Text);
        if (OtherTextBox.Text == "")
        {
            tip.TipPercent = 0;
            foreach (ListItem item in TipPercentsRadioButtonList.Items)
            {
                if (item.Selected)
                {
                    if (item.Text.Equals("Ten Percent"))
                    {
                        tip.TipPercent = 0.1;
                    }
                    else if (item.Text.Equals("Fifteen Percent"))
                    {
                        tip.TipPercent = 0.15;
                    }
                    else if (item.Text.Equals("Twenty Percent"))
                    {
                        tip.TipPercent = 0.2;
                    }
                    else
                    {
                        tip.TipPercent = 0;
                    }
                } // end foreach
            }     // end outer if
        }// end outer if
        else
        {
            // Converting the tip percentage into an actual
            // percentage for calculation.
            tip.TipPercent = double.Parse(OtherTextBox.Text) / 100;
        }

        ResultLabel.Text = "Amount: " + tip.MealAmount.ToString() + "<br/>" +
                           "Tip :" + tip.CalculateTip().ToString("$#.##0.00") + "<br/>" +
                           "Tax: " + tip.CalculateTax().ToString("$#.##0.00") + "<br/>" +
                           "Total: " + tip.CalculateTotal().ToString("$#.##0.00");
    }
    protected void GetInfo()
    {
        Tip tip = new Tip();    //declars this a new constructor
        tip.MealAmount = double.Parse(MealTextBox.Text);    //double.Parse will convert any text into a number
        if (OtherTextBox.Text == "")
        {
            tip.TipPercent = 0; //if no tip selected leave tip amount at 0

            foreach (ListItem item in TipPercentRadioButtonList1.Items)
            {
                if (item.Selected)
                {

                }
                if (item.Text.Equals("Ten Percent"))
                {
                    tip.TipPercent = .1;
                }//end ten percent

                else if (item.Text.Equals("Fifteen Percent"))
                {
                    tip.TipPercent = .15;
                }//end 15 percent

                else if (item.Text.Equals("Twenty Percent"))
                {
                    tip.TipPercent = .2;
                }//end 20 percent
            }//end inner if statement
        }//end outter if statement
    
        else
        {
            tip.TipPercent = double.Parse(OtherTextBox.Text);
        }//end else 

        ResultLabel.Text = "Amount" + tip.MealAmount.ToString() + "<br/>" +
            "Tip: " + tip.CalculateTip().ToString("$#,##0.00") + "<br/>" +
            "Tax: " + tip.CalculateTax().ToString("$#,##0.00") + "<br/>" +
            "Total: " + tip.CalculateTotal().ToString("$#,##0.00");
        
    }//end GetInfo
Beispiel #8
0
    protected void GetInfo()
    {
        //Declares as new tip
        Tip tip = new Tip();

        //assigning value in text box
        //parse looks at text in text box and throws it into a double, and if it cannot do so it gives an error
        tip.MealAmount = double.Parse(MealTextBox.Text);
        if (OtherTextBox.Text == "")
        {
            //Loops through each list item in TipPercentsRadioButtonList
            foreach (ListItem item in TipPercentsRadioButtonList.Items)
            {
                if (item.Selected == true)
                {
                    if (item.Text.Equals("Ten Percent"))
                    {
                        tip.TipPercent = .1;
                    }
                    else if (item.Text.Equals("Fifteen Percent"))
                    {
                        tip.TipPercent = .15;
                    }
                    else if (item.Text.Equals("Twenty Percent"))
                    {
                        tip.TipPercent = .2;
                    }
                } //End if selected
            }     //end foreach
        }         //end outer if
        else
        {
            tip.TipPercent = double.Parse(OtherTextBox.Text);
        }

        ResultLabel.Text = "Amount:" + tip.MealAmount.ToString() + "<br/>"
                           + "Tip: " + tip.CalculateTip().ToString("$#, ##0.00") + "<br/>"
                           + "Tax: " + tip.CalculateTax().ToString("$#, ##0.00") + "<br/>"
                           + "Total: " + tip.CalculateTotal().ToString("$#, ##0.00");
    }
Beispiel #9
0
    protected void GetInfo()
    {
        //getting the value of tip
        Tip tip = new Tip();

        //looping through texbox value and gives out an error if done wrong
        tip.MealAmount = double.Parse(MealTheBox.Text);
        if (OtherTextBox.Text == "")
        {
            //the looping starts here
            foreach (ListItem item in TipPercentsRadioButtonList.Items)
            {
                if (item.Selected == true)
                {
                    if (item.Text.Equals("Ten Percent"))
                    {
                        tip.TipPercent = .1;
                    }
                    else if (item.Text.Equals("Fifteen Percetn"))
                    {
                        tip.TipPercent = .15;
                    }
                    else if (item.Text.Equals("Twenty Percent"))
                    {
                        tip.TipPercent = .2;
                    }
                } //end if selected
            }     //end foreach
        }         //end outer if
        else
        {
            tip.TipPercent = double.Parse(OtherTextBox.Text);
        }

        ResultLabel.Text = "Amount: " + tip.MealAmount.ToString() + "<br/>" +
                           "Tip: " + tip.CalculateTip().ToString("$#,##0.00") + "<br/>" +
                           "Tax: " + tip.CalculateTax().ToString("$#,##0.00") + "<br/>" +
                           "Total: " + tip.CalculateTotal().ToString("$#,##0.00");
    }
Beispiel #10
0
    protected void GetInfo()
    {
        Tip tip = new Tip();

        //assigning value
        tip.MealAmount = double.Parse(MealTextBox.Text);

        if (OtherTextBox.Text == "")
        {
            tip.TipPercent = 0;
            foreach (ListItem item in TipPercentsRBL.Items)
            {
                if (item.Selected == true)
                {
                    if (item.Text.Equals("Ten Percent"))
                    {
                        tip.TipPercent = .1;
                    }
                    else if (item.Text.Equals("Fifteen Percent"))
                    {
                        tip.TipPercent = .15;
                    }
                    else if (item.Text.Equals("Twenty Percent"))
                    {
                        tip.TipPercent = .2;
                    }
                }
            }
        }
        else
        {
            tip.TipPercent = double.Parse(OtherTextBox.Text);
        }

        ResultLabel.Text = "<br/>Meal Amount: " + tip.MealAmount.ToString("$#,##0.00") + "<br/>" +
                           "Tip: " + tip.CalculateTip().ToString("$#,##0.00") + "<br/>" +
                           "Tax: " + tip.CalculateTax().ToString("$#,##0.00") + "<br/>" +
                           "Total: " + tip.CalculateTotal().ToString("$#,##0.00");
    }
Beispiel #11
0
    protected void GetInfo()
    {
        Tip tip = new Tip();

        tip.MealAmount = double.Parse(MealTextbox.Text);
        if (OtherTextBox.Text == "")
        {
            tip.TipPercent = 0;
            foreach (ListItem item in TipPercentsRadioButtonList.Items)
            {
                if (item.Selected)
                {
                    if (item.Text.Equals("10%"))
                    {
                        tip.TipPercent = .1;
                    }
                    else if (item.Text.Equals("15%"))
                    {
                        tip.TipPercent = .15;
                    }
                    else if (item.Text.Equals("20%"))
                    {
                        tip.TipPercent = .2;
                    }
                }
            }
        }
        else
        {
            tip.TipPercent = double.Parse(OtherTextBox.Text);
        }

        ResultLabel.Text = "Amount: " + tip.MealAmount.ToString() + "<br/>" +
                           "Tip: " + tip.CalculateTip().ToString("$#,##0.00") + "<br/>" +
                           "Tax: " + tip.CalculateTax().ToString("$#,##0.00") + "<br/>" +
                           "Tax: " + tip.CalculateTotal().ToString("$#,##0.00");
    }
Beispiel #12
0
    protected void GetInfo()
    {
        Tip tip = new Tip();

        tip.MealAmount = double.Parse(MealTextBox.Text);

        foreach (ListItem item in TipPercentsRadioButtonList.Items)
        {
            if (item.Selected == true)
            {
                if (item.Text.Equals("Ten Percent"))
                {
                    tip.TipPercent = .10;
                }
                else if (item.Text.Equals("Fifteen Percent"))
                {
                    tip.TipPercent = .15;
                }
                else if (item.Text.Equals("Twenty Percent"))
                {
                    tip.TipPercent = .20;
                }
                else if (item.Text.Equals("Other"))
                {
                    tip.TipPercent = .1 * double.Parse(OtherTextBox.Text);
                }
                else
                {
                    tip.TipPercent = (0);
                }
            }
        }
        ResultLabel.Text = "Amount " + tip.MealAmount.ToString("$#,##0.00") + "<br/" +
                           "Tip: " + tip.CalculateTip().ToString("$#,##0.00") + "<br/>" +
                           "Tax: " + tip.CalculateTax().ToString("$#,##0.00") + "<br/>" +
                           "Total: " + tip.Total().ToString("$#,##0.00");
    }