Question: You are creating a program for an auto-repair shop. Write the following methods as instructed. Written in C# Call all functions from main using literals.
You are creating a program for an auto-repair shop. Write the following methods as instructed. Written in C# Call all functions from main using literals.
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.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
