Question

Create a program named TipCalculation that includes two overloaded methods named DisplayTipInfo. One should accept a...

Create a program named TipCalculation that 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

In order to prepend the $ to currency values, the program will need to use the CultureInfo.GetCultureInfo method. In order to do this, include the statement using System.Globalization; at the top of your program and format the output statements as follows: WriteLine("This is an example: {0}", value.ToString("C", CultureInfo.GetCultureInfo("en-US")));

0 0
Add a comment Improve this question Transcribed image text
Answer #1

PROGRAM::

using System;
using System.Globalization;
class HelloWorld {
static void Main() {
DisplayTipInfo(30.00, 0.20);
DisplayTipInfo(30.00, 5);
}
static void DisplayTipInfo(double mealPrice, double tipRate)
{
double tipValue;
tipValue = mealPrice*tipRate;
double totalBill = tipValue+mealPrice;
Console.WriteLine("Meal price: {0}. Tip percent: {1}", mealPrice.ToString("C", CultureInfo.GetCultureInfo("en-US")), tipRate.ToString("C", CultureInfo.GetCultureInfo("en-US")));
Console.WriteLine("Tip in dollars: {0}. Total bill: {1}", tipValue.ToString("C", CultureInfo.GetCultureInfo("en-US")), totalBill.ToString("C", CultureInfo.GetCultureInfo("en-US")));
}
static void DisplayTipInfo(double mealPrice, int tipValue)
{
double tipPercent = tipValue/mealPrice;
double temp = tipValue;
double totalBill = temp + mealPrice;
Console.WriteLine("Meal price: {0}. Tip percent: {1}", mealPrice.ToString("C", CultureInfo.GetCultureInfo("en-US")), tipPercent.ToString("C", CultureInfo.GetCultureInfo("en-US")));
Console.WriteLine("Tip in dollars: {0}. Total bill: {1}", tipValue.ToString("C", CultureInfo.GetCultureInfo("en-US")), totalBill.ToString("C", CultureInfo.GetCultureInfo("en-US")));
}
}

SCREENSHOTS::

using System; using System. Globalization; class HelloWorld { static void Main() { DisplayTipInfo(30.00, 0.20); Display TipInMeal price: $30.00. Tip percent: $0.20 Tip in dollars: $6.00. Total bill: $36.00 Meal price: $30.00. Tip percent: $0.17 Tip i

Add a comment
Know the answer?
Add Answer to:
Create a program named TipCalculation that includes two overloaded methods named DisplayTipInfo. One should accept a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C# Create an application named JobDemo that declares and uses Job objects. The Job class holds...

    C# Create an application named JobDemo that declares and uses Job objects. The Job class holds job information for a home repair service. The class has five properties that include: JobNumber - The job number Customer - The customer name Description - The job description Hours - The estimated hours price - The price for the job Create a constructor that requires parameters for all the data except price. Include auto-implemented properties for the job number, customer name, and job...

  • Please Help in C#, Let me know if you have any questions. Please make sure the...

    Please Help in C#, Let me know if you have any questions. Please make sure the program passes the checks Checks: Question: My code works, it just this needs to be added there which I don't know what I need to do.    In order to prepend the $ to currency values, the program will need to use the CultureInfo.GetCultureInfo method. In order to do this, include the statement using System.Globalization; at the top of your program and format the output...

  • c# Instructions In Chapter 5, you wrote a HomeSales application for three salespeople: Danielle, Edward, and...

    c# Instructions In Chapter 5, you wrote a HomeSales application for three salespeople: Danielle, Edward, and Francis. Now, using the code you wrote in Chapter 5, Programming Exercise 5, modify the program to use arrays to store the salesperson names, allowed initials, and accumulated sales values. In order to prepend the $ to currency values, the program will need to use the CultureInfo.GetCultureInfo method. In order to do this, include the statement using System. Globalization; at the top of your...

  • In Chapter 5, you wrote a HomeSales application for three salespeople: Danielle, Edward, and Francis. Now,...

    In Chapter 5, you wrote a HomeSales application for three salespeople: Danielle, Edward, and Francis. Now, using the code you wrote in Chapter 5, Programming Exercise 5, modify the program to use arrays to store the salesperson names, allowed initials, and accumulated sales values. In order to prepend the $ to currency values, the program will need to use the CultureInfo.GetCultureInfo method. In order to do this, include the statement using System.Globalization; at the top of your program and format...

  • In Chapter 5, you wrote a HomeSales application for three salespeople: Danielle, Edward, and Francis. Now,...

    In Chapter 5, you wrote a HomeSales application for three salespeople: Danielle, Edward, and Francis. Now, using the code you wrote in Chapter 5, Programming Exercise 5, modify the program to use arrays to store the salesperson names, allowed initials, and accumulated sales values. In order to prepend the $ to currency values, the program will need to use the CultureInfo.GetCultureInfo method. In order to do this, include the statement using System.Globalization; at the top of your program and format...

  • Create a class named Billing that includes four overloaded computeBill() methods for a photo book store....

    Create a class named Billing that includes four overloaded computeBill() methods for a photo book store. When computeBill() receives a single parameter, it represents the price of one photo book ordered. Add 8.5% tax, and return the total due. When computeBill() receives two parameters, they represent the price of a photo book and the quantity ordered. Multiply the two values, add 8.5% tax and return the total due. When computeBill() receives three parameters, they represent the price of a photo...

  • Java I: Create a Java program that will accept the price of an item and the...

    Java I: Create a Java program that will accept the price of an item and the quantity being purchased of that item. After accepting the input, calculate the amount of the purchase (based on the price and quantity), calculate the sales tax on the purchase, then output the product price, quantity, subtotal, sales tax, and the total sale based on the output format shown below. Structure your file name and class name on the following pattern: The first three letters...

  • Write a class named MonthDays. The class’s constructor should accept two arguments: l An integer for...

    Write a class named MonthDays. The class’s constructor should accept two arguments: l An integer for the month (1 = January, 2 February, etc). l An integer for the year The class should have a method named getNumberOfDays that returns the number of days in the specified month. The method should use the following criteria to identify leap years: 1. Determine whether the year is divisible by 100. If it is, then it is a leap year if and if...

  • Java programming Create a simple tip calculator called TipCalcMethod. Your program should read in the bill...

    Java programming Create a simple tip calculator called TipCalcMethod. Your program should read in the bill amount from the command-line, then show 3 tip amounts: 15%, 20% and 25% of the bill. Don't worry about rounding the result to two decimal places, but make sure that the result includes cents (not just dollars). This program will be different than your first Tipcalc program because you will writea method to calculate the tip amount. program will have 2 methods: main) and...

  • (To be written in Java code) Create a class named CollegeCourse that includes the following data...

    (To be written in Java code) Create a class named CollegeCourse that includes the following data fields: dept (String) - holds the department (for example, ENG) id (int) - the course number (for example, 101) credits (double) - the credits (for example, 3) price (double) - the fee for the course (for example, $360). All of the fields are required as arguments to the constructor, except for the fee, which is calculated at $120 per credit hour. Include a display()...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT