Answered step by step
Verified Expert Solution
Link Copied!

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#

image text in transcribed

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() 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

Intelligent Information And Database Systems 6th Asian Conference Aciids 2014 Bangkok Thailand April 7 9 2014 Proceedings Part I 9 2014 Proceedings Part 1 Lnai 8397

Authors: Ngoc-Thanh Nguyen ,Boonwat Attachoo ,Bogdan Trawinski ,Kulwadee Somboonviwat

2014th Edition

3319054759, 978-3319054759

More Books

Students also viewed these Databases questions

Question

What is Working Capital ? Explain its types.

Answered: 1 week ago

Question

7. Discuss the implications of a skill-based pay plan for training.

Answered: 1 week ago

Question

4. Make recommendations on steps to take to melt the glass ceiling.

Answered: 1 week ago