Question

This is in C#. Please use comment blocks. I am trying to learn. Thanks a bunch!...

This is in C#. Please use comment blocks. I am trying to learn. Thanks a bunch!

Your instructor enjoys running races of different distances. Write a program to allow him to calculate his pace for a race. Your program should ask for following:

  • The time in hours, minutes, and seconds
  • The distance of the race
  • If that distance is in km or miles    and should output the following:
  • The time input
  • The distance in miles The distance in km
  • The pace of the race in minutes and seconds per mile The pace of the race in minutes and seconds per km

Paces should be displayed to the nearest seconds. Distances should be displayed to precisely 1 decimal place. Your calculations should be done at full precision. E.g:

1:53:30 (1 hour, 53 minutes, 30 seconds) for 13.1 miles (a half marathon) is 8:40 per mile (8 minute and 40 seconds)

Your output should look like this

Time: 1:53:30

Distance in miles: 13.1 Distance in km: 21.1

Pace in minutes per mile: 8:40 Pace in minutes per km: 5:23

Homework Answers

Answer #1

using System;

public class PaceCalculation

{

public static void Main()

{

float dist , hrs, min, sec, tsec, mph, mps, kph, distmiles;

Console.Write(" Enter time - Hour: ");

hrs = Convert.ToSingle(Console.ReadLine());

Console.Write(" Enter time - Min: ");

min = Convert.ToSingle(Console.ReadLine());

Console.Write(" Enter time - Sec: ");

sec = Convert.ToSingle(Console.ReadLine());

Console.Write(" Enter the distance of race (Km) : ");

dist =Convert.ToSingle(Console.ReadLine());

tsec = (hrs*3600) + (min*60) + sec;

mps = dist/tsec;

kph =( dist/tsec)*(5/18);

mph = kph / 1.609f;

distmiles= dist/1.609f;

Console.Writeline("The time output : " hrs , ":", min , ":",sec);

Console.Writeline("Distance is miles: " , distmiles);

Console.Writeline("Distance is km ", dist);

Console.Writeline("Pace in minutes per mile: ", mps);

Console.Writeline("Pace in minutes per km: ", mph);

Console.Writeline("Pace in hours per km: ", kph);

}

}

EXPLANATION:

you simplyhave to use the formula speed=distance/time.

Know the answer?
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
Similar Questions
Write a function called light_speed that takes as input a row vector of distances in kilometers...
Write a function called light_speed that takes as input a row vector of distances in kilometers and returns two row vectors of the same length. Each element of the first output argument is the time in minutes that light would take to travel the distance specified by the corresponding element of the input vector. To check your math, it takes a little more than 8 minutes for sunlight to reach Earth which is 150 million kilometers away. The second output...
Part A) Use the definition of linear speed to solve one of the four problems below....
Part A) Use the definition of linear speed to solve one of the four problems below. Show your work. Suppose that an object moves on a circle of radius r at a constant speed. If s is the distance traveled in time t on this circle, then the linear speed v of the object is defined as v=st . 1) An object is traveling around a circle with a radius of 7 feet. If in 40 seconds a central angle...
this is a thermodynamics course We want to model energy and mass balance issues involved in...
this is a thermodynamics course We want to model energy and mass balance issues involved in strenuous exercise, for example the running of a marathon. Suppose a 70 kg marathon runner runs at an ≈8 minute/mile pace, completing the 26.2 mile race distance in 210 minutes, or 3.5 hours. a.) Physiological measurements indicate that the total power consumed by an average weight runner (70 kg) at a pace of 8 minutes/mile is about 900 kcal/hour. What is the total energy...
I am trying to make a program in C# and was wondering how it could be...
I am trying to make a program in C# and was wondering how it could be done based on the given instructions. Here is the code that i have so far... namespace Conversions { partial class Form1 { /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.IContainer components = null; /// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protected override void Dispose(bool disposing) { if...
Do all the following problems. I. Choose the best answer for each multiple choice. Please use...
Do all the following problems. I. Choose the best answer for each multiple choice. Please use CAPITAL letters to indicate your answer and write neatly. (30 points) 1. ____ 4.____ 7. ____ 10.____ 13. ____ 2. ____ 5.____ 8. ____ 11.____ 14. ____ 3. ____ 6.____ 9. ____ 12.____ 15. ____ Whenever the population standard deviation is unknown and the population has a normal or near-normal distribution, which distribution is used in developing an interval estimation? A. standard distribution B....
USING C++ The purpose of this assignment is the use of 2-dimensional arrays, reading and writing...
USING C++ The purpose of this assignment is the use of 2-dimensional arrays, reading and writing text files, writing functions, and program planning and development. You will read a data file and store all of the input data in a two dimensional array. You will perform calculations on the data and store the results in the 2 dimensional array. You will sort the array and print the results in a report. Instructions You will read in the same input file...
111.C.1: How Well Do I Respond to Turbulent Change? Instrument Listed to the right are a...
111.C.1: How Well Do I Respond to Turbulent Change? Instrument Listed to the right are a set of statements describing characteristics in a managerial job. If your job had these features, how would you react to them? Use the following rating scale for your answers: his feature would be very unpleasant for me This feature would be somewhat unpleasant for me I'd have no reaction to this feature one way or another; or it would be about equally enjoyable and...
What tools could AA leaders have used to increase their awareness of internal and external issues?...
What tools could AA leaders have used to increase their awareness of internal and external issues? ???ALASKA AIRLINES: NAVIGATING CHANGE In the autumn of 2007, Alaska Airlines executives adjourned at the end of a long and stressful day in the midst of a multi-day strategic planning session. Most headed outside to relax, unwind and enjoy a bonfire on the shore of Semiahmoo Spit, outside the meeting venue in Blaine, a seaport town in northwest Washington state. Meanwhile, several members of...
Delta airlines case study Global strategy. Describe the current global strategy and provide evidence about how...
Delta airlines case study Global strategy. Describe the current global strategy and provide evidence about how the firms resources incompetencies support the given pressures regarding costs and local responsiveness. Describe entry modes have they usually used, and whether they are appropriate for the given strategy. Any key issues in their global strategy? casestudy: Atlanta, June 17, 2014. Sea of Delta employees and their families swarmed between food trucks, amusement park booths, and entertainment venues that were scattered throughout what would...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT