Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using the vim editor, create Go programs that solve the following problems: Please include all the functions. The Triathlon Problem: The number of calories burned

Using the vim editor, create Go programs that solve the following problems: Please include all the functions.

The Triathlon Problem: The number of calories burned per hour by cycling, running, and swimming are 225, 450, and 275, respectively. A person loses 1 pound of weight for each 3,800 calories burned. Write a program to request the number of hours spent at each activity and then display the number of calories burned and the number of pounds worked off.

The Triathlon Problem

Ask the user for the number of triathletes

Have your program loop the inputs, calculations, and outputs for each triathlete

Use the Printf function to format your output

Write a function that does the following:

o A prompt message is passed to this function as the one parameter

o The function will return a float64 and an error

o The function should read the string into a buffered reader. If an error occurs, zero should be returned along with an appropriate error message.

o The function should convert the string to a floating point number. If an error occurs, zero should be returned along with an appropriate error message.

o The function should check to see if the number is not positive. If so, zero should be returned along with an appropriate error message.

o The function should return the floating point number and nil

The main function should call the above function 3 times, once for running, once for swimming, and once for cycling.

The only difference will be the error output messages.

The spacing and formatting precision should exactly mirror that as shown below:

image text in transcribed

/---------------------------------------------------------------------------------------------Text for copy

How many triathletes are there? 3

Athlete #1: Enter cycling hours: 2 Enter running hours: 2 Enter swimming hours: 2 Total calories: XXXX Pounds lost: Y.YY

Athlete #2: Enter cycling hours: 3 Enter running hours: 2 Enter swimming hours: 4 Total calories: XXXX Pounds lost: Y.YY

Athlete #3: Enter cycling hours: 1.7 Enter running hours: 2.11 Enter swimming hours: 1.89 Total calories: XXXX Pounds lost: Y.YY

//---------------------------------------------------------------------------------------------Text for copy

Additional comments throughout the program should be included where appropriate.

File should be run as text files with ".go" extensions and Show output.

How many triathletes are there? 3 Athlete #1: Enter cycling hours: 2 Enter running hours: 2 Enter swimming hours: 2 Total calories: XXXX Pounds lost: Y.YY Athlete #2: Enter cycling hours: 3 Enter running hours: 2 Enter swimming hours: 4 Total calories: XXXX Pounds lost: Y.YY Athlete #3: Enter cycling hours: 1.7 Enter running hours: 2.11 Enter swimming hours: 1.89 Total calories: XXXX Pounds lost: Y. YY How many triathletes are there? 3 Athlete #1: Enter cycling hours: 2 Enter running hours: 2 Enter swimming hours: 2 Total calories: XXXX Pounds lost: Y.YY Athlete #2: Enter cycling hours: 3 Enter running hours: 2 Enter swimming hours: 4 Total calories: XXXX Pounds lost: Y.YY Athlete #3: Enter cycling hours: 1.7 Enter running hours: 2.11 Enter swimming hours: 1.89 Total calories: XXXX Pounds lost: Y. YY

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_2

Step: 3

blur-text-image_3

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

Beginning ASP.NET 2.0 And Databases

Authors: John Kauffman, Bradley Millington

1st Edition

0471781347, 978-0471781349

More Books

Students also viewed these Databases questions