/* CS7 - Assignment 2 * spring 2004 * * This program asks the user for his/her age and resting * heart rate, then calculates the middle of the range of * their training heart rate zone. */ import tio.*; class youridTHR { public static void main (String [] args) { int age, // user's age in years rhr, // resting heart rate (usually between 60 & 80) mhr; // max heart rate, depends on age double thr; // training heart rate - holds final answer System.out.println("This program will calculate your ideal training " + "heart rate."); System.out.println(); // get the necessary input System.out.print("What is your age? "); age = Console.in.readInt(); System.out.print("What is your resting heart rate? (beats/min) "); rhr = Console.in.readInt(); System.out.println(); // apply thr formula mhr = 214 - age; thr = ((mhr - rhr) * 0.75) + rhr; // display result System.out.println("Your training heart is " + thr); } } // NOTE: // thr must be a double because 0.75 appears in the formula, which causes // a "widening" of the values around it. The final type resulting from this // formula is a double because of this.