Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C# Question: Your teacher runs a lot of marathons. Write a program to allow him to find his fastest, slowest and average time of up

C# Question:

Your teacher runs a lot of marathons. Write a program to allow him to find his fastest, slowest and average time of up to 10 races.

Your program should ask for times for each race in hours, minutes and seconds. After 10 races have been entered or the user has typed -1 (to indicate the end of input) you will provide the following output:

Race 1: {time} Race 2: {time} **FASTEST** .... .... Race {n-1}: {time} **SLOWEST** Race {n}: {time} Average time: {time}

You will need to store the input in an array so that you can output them at the end. Obviously the words FASTEST and SLOWEST should be on the correct line. You may not use any built in functions on the arrays to calculate the fastest, slowest and average. Average should be rounded to the closest second.

Starting C# Code~

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks;

namespace TeacherRace { class Program { static void Main(string[] args) { int hours, min, sec; double dis, mil; double val, val2;

double pace1, paceKm; Console.WriteLine("The time in hours minutes and seconds : "); hours = int.Parse(Console.ReadLine()); min = int.Parse(Console.ReadLine()); sec = int.Parse(Console.ReadLine()); Console.WriteLine("The time is" + hours + ":" + min + ":" + sec);

Console.WriteLine("The distance of the race in mile:"); dis = double.Parse(Console.ReadLine());

Console.WriteLine("The distance of the race in kilometers:");

mil = dis * (1.60934); Console.WriteLine(mil); Console.WriteLine("The pace of the race in minutes and seconds per miles");

val = ((hours * 60 * 60) + (min * 60) + sec);

//formula to caluculate pace in min per miles is time/distance and divide the result by 60 val2 = val / dis;

pace1 = val2 / 60; Console.WriteLine(pace1);

Console.WriteLine("The pace of the race in minutes and seconds per kilometers"); paceKm = (pace1 * 0.621371192);

Console.WriteLine(paceKm); Console.ReadLine();

} } }

image text in transcribed

Need to update this code to reflect the comparison outlined in the question. Thanks!

Sample output: file:///c/users/203470/documents/visual studio 2015/Projects/ConsoleApplication eAppl X The time in hours minutes and seconds 23 43 The time isi :23:43 The distance of the race in nile 13.1 The distance of the race in kilometers: 21.082354 The pace of the race in ninutes and seconds per miles 6.39058524173028 The pace of the race in ninutes and seconds per kiloneters 3.97092556923155

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

Inference Control In Statistical Databases From Theory To Practice Lncs 2316

Authors: Josep Domingo-Ferrer

2002nd Edition

3540436146, 978-3540436140

More Books

Students also viewed these Databases questions