In: Computer Science
Write the pseudocode that prompts the user for their first and last name. Display the first initial of their first name and their last name to the user.
Ask the user to input a phone number.
The program checks which part of Colorado a phone number is from using the values below.
If the second digit of the phone number is one of the below digits, print the phone number and which part of Colorado it is from. If none of the digits are entered, display the phone number and state it is not in Colorado.
If the number is in Estes Park, the user should see: phone number + “is in Estes Park, it is time to go pick up your new Corgi puppy!”
If the second digit of a phone number is:
0 = Boulder
1 = Colorado Springs
2 = Denver
7 = Estes Park
PSEUDOCODE:
//taking input for first and last names
fName = input.nextLine();
lName = input.nextLine();
//print out the name in required format
System.out.println(fName.toCharArray[0] + lName );
//taking input phone number
phoneNo = input.nextLine();
//converting phonenumber to character array
//and check the second digit of the phone number
char[] phoneNoArray = phoneNo.toCharArray() ;
if (phoneNoArray[1] == 0) {
System.out.println(phoneNo + " is in Boulder");
}
else if (phoneNoArray[1] == 1) {
System.out.println(phoneNo + " is in Colorado Springs");
}
else if (phoneNoArray[1] == 2) {
System.out.println(phoneNo + " is in Denver");
}
else if (phoneNoArray[1] == 7) {
System.out.println(phoneNo + " is in Estes Park, it is time to go
pick up your new Corgi puppy!");
}
else {
System.out.println(phoneNo + " state is not in Colorado");
}