This homework is due electronically by 10 a.m. on Friday 10 February 2006. Submission details are at the bottom of this page.
PurposeYou have successfully mastered the Olympic Triathlon and now are looking for a challenge: you want to consider the Ironman Triathlon but you're unsure how long it might take given your current times on the Olympic Triathlon (the Ironman Triathlon is considerably longer than the Olympic Triathlon). For this homework, you are to write a program that will compute the expected duration for the Ironman Triathlon, optimistically assuming that you're able to keep the same pace as you did on the three phases of your Olympic Triathlon (swim, bike, run). The user will have to input three values:
The program will then compute and print out the following output values:
BackgroundAll Triathlons have three parts: a swim, a bike ride, and a run. There are a few different triathlon distances -- we are focusing on only two of them.
You should use these values in order to get the same results we show below. If you use similar values (such as 112 miles for the bike ride), you will still get full credit, but your output will be slightly different than what is displayed below, and thus it will be harder for you to test your program. DesignThe program will have the following seven steps:
You should be able to determine the formulas for the computations -- see a TA or professor for help if you are unsure about them. When asking for input, please only ask for those 3 values -- the program is going to be run automatically, so if you ask for more input values, your program will not execute correctly for the graders. While we have provided most of the design for this program above, you need to provide some design yourself -- in particular, you need to figure out the formula for computing the various output values, what variables will be needed to store them, and how to implement those computations. How and where to startWe have provided a skeleton Triathlon.java file for you to start with. Please don't change the class name -- doing so will cause it not to compile correctly and result in a loss of lots of points. The best way to proceed is to go through the seven steps described above, testing the program after each step or two. For example, after you write the code to read in the input from the user, you should print those values out to the screen, so that you can test your input routines. And after you make some partial calculations, print those out to the screen to test the program. You are welcome to try to write the whole program and debug it all at once -- however, this will take you much more time than testing it incrementally. Of course, if you have lots of print statements in there, you should probably remove them when the program is working properly, so that the output looks similar to what is shown below. Lastly, be sure you fully understand how to do the conversions before you try to program that in Java. Lastly, you may want to look at the BMICalculator.java program (also on page 75 of the textbook and discussed in lecture). This program, while it computes something different, uses a lot of the same steps described above. Good programming practicesThe following are considered good programming practices. All homeworks must include these whenever possible. Not including them will receive points off from the grade. The BMICalculator.java program (on page 75 of the textbook) is an example of a program that follows most of these practices (all but the test code part).
When we test your program, we will only use positive values (i.e., greater than zero) for the input values. You only need to test with these types of values as well. Sample executionYour program needs to print out similar information, but the format does not have to be the same. However, the values computed should be the same or very similar. Note that the text in red is what was input by the user. And don't worry about really long decimal numbers (such as 2.533333333333333 ) -- we'll see how to convert this into 2.53 (or similar) later in the semester. Are you ready for an Ironman Triathlon? Let's find out! Please enter how long each leg of an Olympic Triathlon took in hours: The swimming part: 1 The biking part: 2 The running part: 1 You entered the following times: Swim: 1.0, Bike: 2.0, Run: 1.0 You swam at a rate of: 40.0 min/km (64.3707756678468 min/mile) You biked at a rate of: 3.0 min/km (4.82780817508851 min/mile) You ran at a rate of: 6.0 min/km (9.65561635017702 min/mile) At this rate, you would do an Ironman in: Swim: 2.533333333333333 hr. Bike: 9.0 hr. Run: 4.2195 hr. For a total of 15.752833333333333 hrs! GradingThe following lists the criteria that the graders will be look at when the homework is graded. Note that these criteria will not be provided on the other homeworks, only on this first one. Also, the points for each of the following criteria have not yet been determined.
If your program does not compile, you will receive 25 points off, in addition to any other penalties. If you do not understand a compilation error, please see a TA or professor (thus, you probably don't want to wait until the night before to start this homework). We have lots of office hours available, please make use of them! SubmissionWhen you are finished, submit the Triathlon.java file. You will notice that we ask more survey questions for the homeworks. |