Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- //Ethan Cha Creating a phone keypad and assigning them to letters
- public class Hw7P02 {
- public static void main(String[] args) {
- Scanner in = new Scanner(System.in);
- //ask for user input
- System.out.print("Enter input: ");
- String numbers = in.next();
- //makes it so that if they enter upper case, it returns as lowercase
- String number = numbers.toLowerCase();
- //makes it so that they can only enter 10 characters, no more no less
- for(int number = 0; number.length() < 10; number++ ){
- if((aa == 'a') || ( aa == 'b') || ( aa == 'c')){
- aa = '2';
- }
- else if((aa == 'd') || (aa == 'e') || (aa == 'f')){
- aa = '3';
- }
- else if((aa == 'g') || (aa == 'h') || (aa == 'i')){
- aa = '4';
- }
- else if((aa == 'j') || (aa == 'k') || (aa == 'l')){
- aa = '5';
- }
- else if((aa == 'm') || (aa == 'n') || (aa == 'o')){
- aa = '6';
- }
- else if((aa == 'p') || (aa == 'q') || (aa == 'r') || (aa == 's')){
- aa = '7';
- }
- else if((aa == 't') || (aa == 'u') || (aa == 'v')){
- aa = '8';
- }
- else if((aa == 'w') || (aa== 'x') || (aa == 'y') || (aa == 'z')){
- aa = '9';
- }
- }
- System.out.println("Phone Number: " + "(" + aa + ab + ac + ")" + ad + ae + af + "-" + ag + ah + ai + aj);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement