Question

In: Computer Science

6. Store your important phone numbers in a hash. Write a program to look up umbers...

6. Store your important phone numbers in a hash. Write a program to look up umbers by the person’s name in perl language.

Solutions

Expert Solution

To write code for important phone number in Hash and look up numbers by the person's name in perl language;

Before implementing this code we have to write some explaination of this code;

Initialization of hash & fetching an element to the hash: -

A hash variable can be initialized with key/value pair during it's declaration time . There are two ways for initialize the hash variable one is using => which is called the fat arrow or fat comma .

And the second one is to put the key/value pair in double quote(" ") & separated by comma(,) .

To access the individual element from hash use the symbol ($).

These are the things we are going to used in our code:

#perl program to demonstrate the

#Fetching an element of a hash with Mobile number.

#creating hash

%rateof = (" Amol "=> 9834562730 , " john " => 9934562738, " krish " => 9735261781 );

#fetching an element of hash

print  "$rateof { 'Amol'}\n" ;

print "$rateof {'john'}\n;

print "$rateof {'krish'}\n" ;

output:

9834562730

9934562738

9735261781


Related Solutions

You will write a program that prompts the user to enter a 7-digit phone numbers, and...
You will write a program that prompts the user to enter a 7-digit phone numbers, and finds the 3- and 4-letter words that map to the phone number, according to the restrictions outlined earlier. A sample run: unixlab% java MapNumbers Enter name of dictionary file: words10683 Enter a test word (3 letters): cat Test word maps to 228 Enter telephone number (7 digits, no 0's or 1's, negative to quit): 2282273 Options for first 3 digits: act cat bat Options...
Write a program in Python to print all possible combinations of phone numbers. The length of...
Write a program in Python to print all possible combinations of phone numbers. The length of the number will be given. Also 3 digits will be given, which can not be used. No two consecutive digits can be same. A number containing 4 would always have 4 in the beginning.
Write a program that takes a set of m numbers up to size n and save...
Write a program that takes a set of m numbers up to size n and save them in an array. The program then allows you to search for any number in the array with O(1).
C++ Bubble Sort Write a program that ask user to enter 7 numbers and store that...
C++ Bubble Sort Write a program that ask user to enter 7 numbers and store that in array. Display that all numbers before and after performing Bubble sort. You must have to create new function with required parameter to perform Bubble sort. Sample Run :- Enter 1 number :- 1 Enter 2 number :- 5 Enter 3 number :- 7 Enter 4 number :- 45 Enter 5 number :- 90 Enter 6 number :- 6 Enter 7 number :- 55...
Write an application, Phone Numbers, that creates and prints a random phone number of the form...
Write an application, Phone Numbers, that creates and prints a random phone number of the form XXX-XXX-XXXX. Include the dashes in the output. The phone number has some constraints. Do not let the first three digits contain an 3 or 7 (but do not be more restrictive than that) and ensure that the second set of three digits is not greater than 825. Note that any of the digits can be zero and zeroes should be shown.
WRITING: Write a couples sentence cell phone use policy for your store. This policy will be...
WRITING: Write a couples sentence cell phone use policy for your store. This policy will be displayed throughout the store (in a banner,sign). Add a one page cover note explaining where and how the notice will be distributed. This cover note is only for the employees of your cafe. Backstory: You own a small new-and-used book store and café with free wireless Internet access. You enjoy the calm, quiet atmosphere of your store and like that your customers choose your...
in C++, Write a program that asks the user to enter 6 numbers. Use an array...
in C++, Write a program that asks the user to enter 6 numbers. Use an array to store these numbers. Your program should then count the number of odd numbers, the number of even numbers, the negative, and positive numbers. At the end, your program should display all of these counts. Remember that 0 is neither negative or positive, so if a zero is entered it should not be counted as positive or negative. However, 0 is an even number....
Write a program to insert the following elements into a hash table of size 17. The...
Write a program to insert the following elements into a hash table of size 17. The hash function is X mod 17 where X is the input element.   6, 12, 34, 29, 28, 11, 23, 7, 0, 33, 30, 45 Use linear probing to resolve any collisions.
Write a C program that asks the user to enter 15 integer numbers and then store them in the array.
Write a C program that asks the user to enter 15 integer numbers and then store them in the array. Then, the program will find the second largest element in array and its index without sorting the array. For example, In this array {-55,-2,1, 2, -3, 0, 5, 9, 13, 1, 4, 3, 2, 1, 0}, the second largest element is 9 [found at index 7].
Write a C++ program to swap two numbers and show your output
Write a C++ program to swap two numbers and show your output
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT