Create a C# Console program named TipCalculationthat includes two overloaded methods named DisplayTipInfo.

One should accept a meal price and a tip as doubles (for example, 30.00 and 0.20, where 0.20 represents a 20 percent tip).
The other should accept a meal price as a double and a tip amount as an integer (for example, 30.00 and 5, where 5 represents a $5 tip).
Each method displays the meal price, the tip as a percentage of the meal price, the tip in dollars, and the total of the meal plus the tip. Include a Main() method that demonstrates each method.
For example if the input meal price is 30.00 and the tip is 0.20, the output should be:
Meal price: $30.00. Tip percent: 0.20
Tip in dollars: $6.00. Total bill $36.00
Looks like this so far:
using static System.Console;
class TipCalculation
{
static void Main()
{
// Write your main here
}
public static void DisplayTipInfo(double price, double tipRate)
{
1}
public static void DisplayTipInfo(double price, int tipInDollars)
{
}

}

Respuesta :

Answer:

The code for the program is given in the explanation

Explanation:

using System;

using static System.Console;

class TipCalculation

{

   //definition of the Main()

   static void Main()

   {      

       double dPrice, dTip;

       int iTip;

       //prompt and accept a meal price and a tip as doubles

       Write("Enter a floating point price of the item : ");

       dPrice = Convert.ToDouble(Console.ReadLine());

       Write("Enter a floating point tip amount: ");

       dTip = Convert.ToDouble(Console.ReadLine());

       //call the method DisplayTipInfo()

       //with doubles

       DisplayTipInfo(dPrice, dTip);

       //prompt and accept a meal price as a double

       //and a tip amount as an integer

       Write("\nEnter a floating point price of another item : ");

       dPrice = Convert.ToDouble(Console.ReadLine());

       Write("Enter a integral tip amount: ");

       iTip = Convert.ToInt32(Console.ReadLine());

       //call the method DisplayTipInfo()

       //with double and an integer

       DisplayTipInfo(dPrice, iTip);

   }

   //definition of the method DisplayTipInfo()

   //accept a meal price and a tip as doubles

   public static void DisplayTipInfo(double price, double tipRate)

   {

       //find the tip amount

       double tipAmount = price * tipRate;

       //find the total amount

       double total = price + tipAmount;

       //print the output

       WriteLine("Meal price: $" + price.ToString("F") + ". Tip percent: " + tipRate.ToString("F"));

       WriteLine("Tip in dollars: $" + tipAmount.ToString("F") + ". Total bill $" +          total.ToString("F"));

   }

   //definition of the method DisplayTipInfo()

   //accept a meal price and a tip as doubles

   //a meal price as a double and a tip amount as an integer

   public static void DisplayTipInfo(double price, int tipInDollars)

   {

       //find the tip rate

       double tipRate = tipInDollars / price;

       //find the total amount

       double total = price + tipInDollars;

       //print the output

       WriteLine("Meal price: $" + price.ToString("F") + ". Tip percent: " +                 tipRate.ToString("F"));

       WriteLine("Tip in dollars: $" + tipInDollars.ToString("F") + ". Total bill $" +               total.ToString("F"));

   }

}

In this exercise we have to write a C code requested in the statement, like this:

find the code in the attached image

We can write the code in a simple way like this below:

using System;

using static System.Console;

class TipCalculation

{

  //definition of the Main()

  static void Main()

  {    

      double dPrice, dTip;

      int iTip;

      Write("Enter a floating point price of the item : ");

      dPrice = Convert.ToDouble(Console.ReadLine());

      Write("Enter a floating point tip amount: ");

      dTip = Convert.ToDouble(Console.ReadLine());

      DisplayTipInfo(dPrice, dTip);

      Write("\nEnter a floating point price of another item : ");

      dPrice = Convert.ToDouble(Console.ReadLine());

      Write("Enter a integral tip amount: ");

      iTip = Convert.ToInt32(Console.ReadLine());

      DisplayTipInfo(dPrice, iTip);

  }

  public static void DisplayTipInfo(double price, double tipRate)

  {

      double tipAmount = price * tipRate;

      double total = price + tipAmount;

      WriteLine("Meal price: $" + price.ToString("F") + ". Tip percent: " + tipRate.ToString("F"));

      WriteLine("Tip in dollars: $" + tipAmount.ToString("F") + ". Total bill $" +          total.ToString("F"));

  }

  public static void DisplayTipInfo(double price, int tipInDollars)

  {

         double tipRate = tipInDollars / price;

      double total = price + tipInDollars;

      WriteLine("Meal price: $" + price.ToString("F") + ". Tip percent: " +                 tipRate.ToString("F"));

      WriteLine("Tip in dollars: $" + tipInDollars.ToString("F") + ". Total bill $" +               total.ToString("F"));

  }

}

See more about C code at brainly.com/question/19705654

Ver imagen lhmarianateixeira