Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Compile and run below program. Make sure to click on the Output Window. Test the program by entering different characters. Take notes of below program

  1. Compile and run below program.

  2. Make sure to click on the Output Window.

  3. Test the program by entering different characters. Take notes of below program and your observations and include in your comments:

  • Note toUpperCase()method converting the input to upper case letters.

  • Note if the user input more than one letter, note what charAt(0)do.

  1. Submit your work.

    The international standard letter/number mapping found on the telephone is shown below:

1

2 ABC

3 DEF

4 GHI

5 JKL

6 MNO

7 PQRS

8 TUV

9 WXYZ

0

I need notes at the end of the lines of code in Java. For example : import java.util.Scanner; //importing Java Scanner library

// Program # 1

import java.util.Scanner;

public class Program1 {

public static void main(String[] args) {

Scanner input = new Scanner(System.in);

System.out.print("Enter a letter: ");

char ch = input.nextLine().charAt(0);

int number = 0;

switch (Character.toUpperCase(ch))

{

case 'A':

case 'B':

case 'C': number = 2; break;

case 'D':

case 'E':

case 'F': number = 3; break;

case 'G':

case 'H':

case 'I': number = 4; break;

case 'J':

case 'K':

case 'L': number = 5; break;

case 'M':

case 'N':

case 'O': number = 6; break;

case 'P':

case 'Q':

case 'R':

case 'S': number = 7; break;

case 'T':

case 'U':

case 'V': number = 8; break;

case 'W':

case 'X':

case 'Y':

case 'Z': number = 9; break;

default: System.out.println(ch + "is an invalid input ");

System.exit(1);

}

System.out.println("The corresponding number is " + number);

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Microsoft Visual Basic 2005 For Windows Mobile Web Office And Database Applications Comprehensive

Authors: Gary B. Shelly, Thomas J. Cashman, Corinne Hoisington

1st Edition

0619254823, 978-0619254827

More Books

Students also viewed these Databases questions