Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C# project - This exercise called TippingTable.cs (or create a project named Tip

ID: 669814 • Letter: C

Question

C# project - This exercise called TippingTable.cs (or create a project named TippingTable) is based on the You Do It section of the 6th Edition textbook chapter pages 207-210. Your output tipping table should look similar to the figure below here. Your assignment is to modify (or create if you did not do the "You Do It") a version of an app calledTippingTable.cs (as mentioned in the first sentence of this exercise). Your version should prompt the user for the following 4 values rather than having them declared and initialized as constants as it did in the "You Do It". The 4 values are: 1) The lowest tipping percentage (.10 or 10%), 2) The highest tipping percentage (.25 or 25%), 3) The lowest possible restaurant (dinner) bill ($10), and 4) The highest restaurant (dinner) bill ($100).

*************************************************************************

"You Do It"

using System;

namespace TippingTable
{
class Program
{
static void Main(string[] args)
{
Console.BackgroundColor = ConsoleColor.White;
Console.ForegroundColor = ConsoleColor.Black;
Console.Clear();

double dinnerPrice = 10.00;
double tipRate;
double tip;

const double LOWRATE = 0.10;
const double MAXRATE = 0.25;
const double TIPSTEP = 0.05;
const double MAXDINNER = 100.00;
const double DINNERSTEP = 10.00;

Console.Write(" Price");
for (tipRate = LOWRATE; tipRate <= MAXRATE; tipRate += TIPSTEP)
Console.Write("{0, 8}", tipRate.ToString("F"));
Console.WriteLine();
Console.WriteLine("----------------------------------------");

tipRate = LOWRATE;

while (dinnerPrice <= MAXDINNER)
{
Console.Write("{0, 8}", dinnerPrice.ToString("C"));
while (tipRate <= MAXRATE)
{
tip = dinnerPrice * tipRate;
Console.Write("{0, 8}", tip.ToString("F"));
tipRate += 0.05;
}
dinnerPrice += DINNERSTEP;
tipRate = LOWRATE;
Console.WriteLine();
}
}
}
}

ZYCChapter-05 >1 ippingTable crchate.pingabie. 290.25 Price 0.10 0.15 $10.00 1.00 1.50 2.0 2.50 $20.00 2.00 3.00 4.00 5.00 7.50 8.00 10.00 7.50 10.00 12.50 9.00 12.00 15.00 S70.00 7.00 10.50 14.00 17.50 30.00 40.00 50.00 60.00 3.00 4.00 5.00 6.00 4.50 6.00 6.00 80.00 90.00 8.00 12.00 16.00 20.00 9.00 13.50 18.00 22.50 $100.00 10.00 15.00 20.00 25.00 : CChapter-05 >

Explanation / Answer

using System;
namespace TippingTable
{
class Program
{
static void Main(string[] args)
{
Console.BackgroundColor = ConsoleColor.White;
Console.ForegroundColor = ConsoleColor.Black;
Console.Clear();


Console.WriteLine("Enter Dinner Price "dinnerPrice);
double tipRate;
double tip;
Console.WriteLine("Enter Lowest Percentage Rate " LOWRATE);
Console.WriteLine("Enter highest tipping percentage " MAXRATE);
Console.WriteLine("Enter lowest possible restaurant (dinner) bill " TIPSTEP);
Console.WriteLine("Enter highest restaurant (dinner) bill " MAXDINNER);
Console.WriteLine(DINNERSTEP);


Console.Write(" Price");
for (tipRate = LOWRATE; tipRate <= MAXRATE; tipRate += TIPSTEP)
Console.Write("{0, 8}", tipRate.ToString("F"));
Console.WriteLine();
Console.WriteLine("----------------------------------------");

tipRate = LOWRATE;

while (dinnerPrice <= MAXDINNER)
{
Console.Write("{0, 8}", dinnerPrice.ToString("C"));
while (tipRate <= MAXRATE)
{
tip = dinnerPrice * tipRate;
Console.Write("{0, 8}", tip.ToString("F"));
tipRate += 0.05;
}
dinnerPrice += DINNERSTEP;
tipRate = LOWRATE;
Console.WriteLine();
Console.ReadLine();
}
}
}

}