Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Call all functions from main using literals in C#. 1. Write a function named greeting that takes in the customer name and the make of

Call all functions from main using literals in C#.

1. Write a function named greeting that takes in the customer name and the make of their car via parameters. The function should output a personalized greeting. E.g. Welcome to our shop, Ms. Smith. We will be happy to service your VW today. The function should not return anything to the calling method.

2. For your second function, create a function header that takes in a cars make and model via parameters. You will need to create a local accumulator variable named totalPrice, which you will return at the end of the function. We can store string values and double values in parallel arrays and reference these by their index, or position in the array. Start by adding these two local arrays to your function.

String[] services = {"Oil Change", "Tire Rotation", "Air Filter", "Check Fluids"};

double[] prices = {39.99, 49.99, 19.99, 10.99};

Note that the services align with the prices. In other words, an oil change, services[0], costs prices [0], or 39.99. Next, youll need a for loop to iterate through the items to find out what the user wants. Here is your loop header:

for (int index = 0; index < services.length; index ++)

Inside that loop, youll ask if the user wants a service[index] (for instance, Do you want an oil change for your VW Bug?). If the user answers yes, youll add the corresponding price[index] to the accumulator. Your function will need to collect user input here, i.e. youll need to ask the user to answer a question and read and store their answer.

Return the total price to the calling function.

3. Create a third method that takes in total price via parameters, then adds 7% sales tax. Return the charge plus tax to the calling function.

4. Create the last method that takes in a double that represents the time it will take to complete the service and also takes in a double that is the total price accumulated up to this point. Inside your method, write the code that charges $30 for the first hour, $20 for the second hour, and $10 for every hour thereafter. Return the total charge plus service to the calling function.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases On The Web Designing And Programming For Network Access

Authors: Patricia Ju

1st Edition

1558515100, 978-1558515109

More Books

Students also viewed these Databases questions

Question

2. What type of team would you recommend?

Answered: 1 week ago

Question

What was the role of the team leader? How was he or she selected?

Answered: 1 week ago