Chapter 61 Programming Exercises


Exercise 1 — Temperature Conversion

Modify the temperature conversion program so that it converts Celsius to Fahrenheit. Use the formula:

fahr = celsius*9/5 + 32
Click here to go back to the main menu.

Exercise 2 — Two Way Conversion

Add two buttons to the temperature conversion program. Clicking one button converts Fahrenheit to Celsius, clicking the other converts Celsius to Fahrenheit. Add a "clear" button that clears the text in both text fields.

Click here to go back to the main menu.

Exercise 3 — User-friendly Fat Calculator

Modify the calories from fat calculator so that it does not crash when the user enters text that cannot be converted to a double. You might have to look ahead to chapters 80 and 81 for this, or look at the modification done with the temperature converter and try to do something similar.

Click here to go back to the main menu.

Exercise 4 — User-friendly Fat Calculator, with Advice

Further modify the calories from fat calculator so that it includes another TextField that will be set with the text "Too many fat calories" if the percentage of calories from fat is equal or greater than 30 percent, or to "Healthy amount of fat" if the percentage is less than that.

Click here to go back to the main menu.