Java
Write a program that prints the letters corresponding to the numbers on the telephone. So if you were to enter 6 it should print MNO. Now since you do not know how to do a System.in just do you for the number 7. So your code should be like int numberEntered = 7; String value; swtich (numberEntered){ case 1: value = "Nothing definded for 1"; break; case 2 : value = "A,B,C"; break ..... ..... default: value = "Not defined"; break } Make sure your code is formatted.
If you have any doubts, please give me comment...
import java.util.Scanner;
public class TelephoneLetters{
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
System.out.print("Enter number: ");
int numberEntered = scnr.nextInt();
String value;
switch(numberEntered){
case 1:
value = "Nothing undefined for 1";
break;
case 2:
value = "ABC";
break;
case 3:
value = "DEF";
break;
case 4:
value = "GHI";
break;
case 5:
value = "JKL";
break;
case 6:
value = "MNO";
break;
case 7:
value = "PQRS";
break;
case 8:
value = "TUV";
break;
case 9:
value = "WXYZ";
break;
default:
value = "Not defined";
break;
}
System.out.println(numberEntered+" : "+value);
}
}
Get Answers For Free
Most questions answered within 1 hours.