Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Program is to be written in C# Lab Description: Write a program that determines the total time of a car trip. Hints - For this
Program is to be written in C#
Lab Description: Write a program that determines the total time of a car trip. Hints - For this lab make all functions static Step 1 - Declare a constant variable at the class level (just above the Main() function), the variable will be of type double and will represent the distance of the trip. Assign this constant a value of 500.0 Step 2 - At the beginning of Main() declare the following variables An integer variable to represent the car used for the trip An integer variable to represent the speed of the car used for the trip A double variable to represent the total time taken for the trip. Step 3 - Write a void function that has no parameters passed to it. In this function display the value of the constant which represent distance. Call this function from Main(). Step 4 -Write a function that has no parameters passed to it. This function will get the user to choose a car and then returns this value. There are three different cars to choose from, each represented by an integer 1, 2 or 3. For now expect perfect user input. Sample wording for prompt: Please enter the number that represents your vehicle? 1="Honda Civic" 2 ="Toyota Camry" 3="Ford F-150" Call this function from Main() and have the return value assigned to the variable which represents the car used for the trip. Step 5 - Write a function that has a car passed to it and uses a switch statement to determine the speed of that car and returns this value. Car 1 will be given a speed of 10, Car 2 will be given a speed of 20 and Car 3 will be given a speed of 40. Call this function from Main() and have the return value assigned to the variable which represents the speed of the car used for the trip. Step 6 Write a function which will have the speed of the car passed to it and returns the total time taken for the trip. Call this function from Main() and have the return value assigned to the variable which represents the total time taken for the trip. Step 7. Display the total time of this trip to the console. Step 8. Place all the Main() functions code inside of a for loop. Have this loop iterate 3 times. Step 9. After the for loop attempt to display the value of the variable which represents the total time taken for the trip. What issue is occurring?? Step 10. Change the scope of the variables declared in Step 2 so that they are accessible from anywhere inside of the Main() functionStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started