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
