Overview

This lab gives you practice writing user-defined Java methods.

import javax.swing.*       // for JOptionPane methods 

LEGEND: Keyboard    Screen

Task 1: ShowChar

(From Task 5.1) Create a Java main class called ShowChar, with a method named showChar. The method should accept two arguments: a String object and an integer. The integer argument is a character position within the String, with the first position being 0. When the method executes, it should check to make sure the position number is valid for the String given (i.e., that it's in the right range), and then display the character at that position. If the position is out of range, the showChar method should say so.

Use this ShowChar main method to test your showChar method.

Task 2: AreaRectangle

Use the code provided in AreaRectangle as the starting point for a program that asks the user to enter width and length of a rectangle, and then displays the rectangle's area. The program calls the following methods, which have not been written:

Task 3: TempConverter

Write a Java program named TempConverter that prompts the user for a temperature, then for a scale (fahrenheit or celsius) and responds by displaying the equivalent temperature in the other scale. You should write the following two methods:

Some notes to follow:

Welcome to TempConverter!

    32 degrees Fahrenheit == 0 degrees Celsius
    212 degrees Fahrenheit == 100 degrees Celsius
    32 degrees Celsius == 89.6 degrees Fahrenheit
	
Goodbye!
    
Copyright © 1999-2008| Gene Rohrbaugh | Privacy Statement