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(); }
public void CalcTotalTest() { t.BillAmount = 100; t.TipPercent = .20; t.TaxPercent = 9; double taxAmount = t.CalculateTax(); Assert.AreEqual(t.CalculateTotal(), 129.00); }
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
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"); }
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"); }
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"); }
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"); }