# Radio Buttons

Slides Here!

## In Class Exercises (ICEs)

### Part 1: Practice Exercises

Pick from amongst the following problems. Start with any one that you want and try to solve it.  If you get done with that one, then pick another one and work on that, etc, etc.

#### Part 1-A: Two Way Temperature Converter

Create a page that asks the user for the temperature in degrees using a text box, along with a pair of radio buttons.  If the first radio button is checked off then the page will assume that the temperature is in Fahrenheit and convert that number to Celsius.  If the second radio button is checked off then the page will do the opposite - it will assume that the temperature is in Celsius and convert that number to Fahrenheit. Note: You worked on temperature conversion during last week's exercises.

#### Part 1-B: Optional Math Class Style Question About Inverse Functions

NOTE: You don't have to do this one and it will never be on any tests.  It might be fun and/or useful to think about, depending on which math classes you're taking (if any)

Let's say that you want to create another web page that works similar to the one in Part A, except this time for grades.  The idea being that you can convert from your total points (e.g., 595 points out of 700 total) into your overall GPA (e.g., a 3.0) if you select one of the radio buttons, or you can convert from a GPA (such as 4.0) back to your number of points (e.g., 672 out of 700).

Why can't you do this?  If you wanted to talk about this using the language of math, how would you describe the inverse function of the 'points to GPA' function?  It might help also to clarify the domain and range for both the 'points to GPA' function and it's inverse.

#### Part 1-C: Veggie Feedback

Create a page where the user is presented with the following options, via radio buttons:

• Tomato
• Beet
• Carrot
• Potato

The user should click on one of the radio buttons, and then click on a 'normal' button; you should then provide the user with feedback about each vegetable.  Please keep the feedback both positive and family-friendly.

#### Part 1-D: One-Way Converter Page

Create a page where the user is presented with a textbox and several radio button options.  When a button is clicked the page will convert from whatever they typed in into whatever option they've selected.  While you're encouraged to come up with your own options, here's a couple of ideas to get you started:

• The page will help users convert between US dollars and other forms of currency.
The user will type in an amount of money in US dollars.  The user is given the option of converting to Russian Rubles, French Francs, or Japanese Yen.  When the user clicks the button the page will do the conversion and show how many Rubles (or Francs, or Yen) you can currently get for the specified number of US dollars.
• The page will help users convert between different units of measurement that are used in cooking and baking.  The user will type in an amount in cups, and will then be given the option of converting to quarts, tablespoons or teaspoons.  When the user clicks the button the page will display how many quarts/tablespoons/teaspoons are equivalent to that many cups.
• YOUR IDEA HERE!!!
If you have an idea for something else to convert from/to, please use it! :)

#### Part 1-E: Two-Way Converter Page

This exercise builds on the previous one - you'll need to complete the prior one before doing this one.

In the prior exercise you converted from a single unit (say, US dollars) to the user's choice of units (Rubles, Francs, Yen).  For this exercise you should let the user choose which units to convert from in addition to the choice about to convert to.

For example, instead of assuming that the user is typing in U.S. dollars, you should present the user with radio buttons that let them select from US dollars, Rubles, Francs, or Yen as the starting currency, gives them a textbox to type in that starting currency, and then gives them another set of radio buttons to choose the currency that they want to convert to, as pictured below.  When the user clicks on the button the page will convert from the chosen currency to the destination currency.

 What would you like to convert from? US dollars Rubles Francs Yen Type the starting amount here: What would you like to convert to? US dollars Rubles Francs Yen