TelephoneDigitProgram

TelephoneDigitProgram - /* / Program: Telephone Digits /...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
//******************************************************** // Program: Telephone Digits // This is an example of a sentinel-controlled while loop. // This program converts uppercase letters to their // corresponding telephone digits. //******************************************************** / import javax.swing.JOptionPane; i public class TelephoneDigitProgram { public static void main (String[] args) { char letter; //Line 1 String inputMessage; //Line 2 String inputString; //Line 3 String outputMessage; //Line 4 inputMessage = "Program to convert uppercase " + "letters to their corresponding " + "telephone digits.\n" + "To stop the program enter #.\n" + "Enter a letter:"; //Line 5 inputString = JOptionPane.showInputDialog(inputMessage); //Line 6 letter = inputString.charAt(0); //Line 7 while (letter != '#' ) //Line 8 { outputMessage = "The letter you entered is: " + letter + "\n" + "The corresponding telephone " + "digit is: "; //Line 9 //Line 10 { switch (letter) //Line 11 { case 'A':
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 06/17/2011 for the course COMP 2301 taught by Professor Staff during the Spring '10 term at Kennesaw.

Page1 / 3

TelephoneDigitProgram - /* / Program: Telephone Digits /...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online