using System; using System.Collections.Generic; using System.Text; namespace TipExample { /******************************** * This class is used to display the results * of using the tip class. It creates instantiates * two instances of the class so you can compare the * differences between different tip amounts * Steve Conger 10/29/2008 * *********************************/ class Display { //constructor public Display() { //call the display method when this class is //initialized DisplayIt(); } private void DisplayIt() { //Get the amount and tip percent Console.WriteLine("Enter the Meal Amount"); double amount =double.Parse(Console.ReadLine()); Console.WriteLine("Enter the percent for tip"); double percent = double.Parse(Console.ReadLine()); //instantiate the first tip object and pass the parameters Tip tip1 = new Tip(amount, percent); //display the results Console.WriteLine("The tip for {0:C} at {1:P} is {2:C}", amount,tip1.Percent, tip1.CalculateTip()); Console.WriteLine ("The Total is {0:c}", tip1.CalculateTotal()); //get the amount and percent for the second tip object Console.WriteLine("Enter the Meal Amount"); amount = double.Parse(Console.ReadLine()); Console.WriteLine("Enter the percent for tip"); percent = double.Parse(Console.ReadLine()); //instantiate the second tip object Tip tip2 = new Tip(amount, percent); //dispaly the results Console.WriteLine("The tip for {0:C} at {1:P} is {2:C}", amount, tip2.Percent, tip2.CalculateTip()); Console.WriteLine("The Total is {0:c}", tip2.CalculateTotal()); Console.ReadKey(); } } }