Question

In: Computer Science

NASA has decided to go back and use modems to communicate between computers (they must have...

NASA has decided to go back and use modems to communicate between computers (they must have missed the War Games video). In order to provide security, the last 6 digits of the phone number must add to 33. If the fourth number is odd the fifth number must be even. Likewise, if the fourth number is even the fifth number must be odd.

Write a phone number generator that asks for the first four digits. The computer must generate a list of all possible phone numbers that meet the new security rule, and display them as follows:

(XXX) - XXX - XXXX

Solutions

Expert Solution

#include <iostream>

#include <cstdlib>

#include <ctime>

using namespace std;

int main()

{

   int i = 0;

   char playAgain;

   do

   {

       //random number generator

       srand (static_cast<unsigned int>(time(0)));

       //define variables

       int firstFour[5];

      int lastSix[7];

       //Greeting and input of first four numbers

       cout<<"\n\n\t\tWelcome to the NASA's modem number generator"<<endl

<<"\t\tYou will enter the first four digits of the phone number, "<<endl

<<"\t\tand then be given options for the last six numbers. "<<endl

<<"\n\t\tEnter the first four desired numbers: ";

       //while statement to input numbers to array

       for(int i = 0; i < 4; i++)

       {

           cout<<"\n\t\t";

           cout<<i + 1<<". ";

           cin>>firstFour[i];

       }

       //do loop to check if == to 33

       int j=0;

       do

       {

           int i = 0;

           //check if 4th number is even

           if(firstFour[3] % 2 == 0)

           {

               do

               {

                   lastSix[0] = rand() % 9;

               }while(lastSix[0] % 2 == 0);

               for(int i = 1; i < 6; i++)

               {

                   lastSix[i] = rand() % 10;

               }

           }else

               if(firstFour[3] % 2 != 0)

               {

                   do

                   {

                       lastSix[0] = rand() % 10;

                   }while(lastSix[0] % 2 != 0);

               }

               for(int i = 1; i < 6; i++)

               {

                   lastSix[i] = rand()% 10;

               }

               int sum = 0;

               for (int i=0; i<6; i++)

               {

                   sum+= lastSix[i];

               }

             

               if(sum == 33)

               {

                   //display chosen number

                   cout<<"(";

                   for(int i = 0; i < 3; i++)

                   {

               cout<<firstFour[i];

                   }

cout<<")-"<<firstFour[3]<<lastSix[0]<<lastSix[1]<<"-";

                   for(int i = 2; i< 6; i++)

                   {

                       cout<<lastSix[i];

                   }

                   cout<<"\n";

               }

               j++;

       }while(j < 500);

       cout<<"Run again?";

       cin>> playAgain;

   }while (playAgain == 'y');

   system("pause");

   return 0;

}

Sample Output:

                        Welcome to the NASA's modem number generator

                        Enter the first four digits of the phone number,

                        and then give options for the last six numbers.

                        Enter the first four desired numbers:

                        1. 3

                        2. 4

                        3. 5

                        4. 6

(345)-672-4839

(345)-639-6465

(345)-675-6537

(345)-679-5534

(345)-655-7169

(345)-651-7398

(345)-656-7735

(345)-659-7291

(345)-636-8970

(345)-618-7944

(345)-639-6672

Run again? N


Related Solutions

the kelowna go-kart club has decided to build a clubhouse five years from now. it must...
the kelowna go-kart club has decided to build a clubhouse five years from now. it must accumulate $50000 by the end of five years by setting aside a uniform amount from its dues at the end of each year. if the imterest rate is 10 percent, how much must be set aside each year?
The Decision to Lease or Buy at Warf Computers Warf Computers has decided to proceed with...
The Decision to Lease or Buy at Warf Computers Warf Computers has decided to proceed with the manufacture and distribution of the virtual keyboard (VK) the company has developed. To undertake this venture, the company needs to obtain equipment for the production of the microphone for the keyboard. Because of the required sensitivity of the microphone and its small size, the company needs specialized equipment for production. Nick Warf, the company president, has found a vendor for the equipment. Clapton...
NASA has created a heat engine which operates between the sun and the vacuum of the...
NASA has created a heat engine which operates between the sun and the vacuum of the space where the temperature is absolute zero. He says that his engine is nearly 100% efficient. Do you agree with the claim assuming the engine to be totally reversible? Analyse the scenario using equation for efficiency of Carnot engine and Kelvin statement to evaluate your conclusion.
You have decided to go into the business of selling Motorcycles. You have incorporated your business...
You have decided to go into the business of selling Motorcycles. You have incorporated your business under the name of Miller Corporation On January 1, 20X1, you begin by depositing $50,000 cash in the new corporate bank account ? $30,000 of the money is yours and $20,000 is borrowed from your Uncle Mike. For the $30,000, which is yours, you (as Miller Corporation) issue yourself 300 shares of common stock. For the $20,000 borrowed from your uncle, you sign a...
Case Advanced Computers has decided to proceed with the manufacture and distribution of the virtual keyboard...
Case Advanced Computers has decided to proceed with the manufacture and distribution of the virtual keyboard (VK) the company has developed. To undertake this venture, the company needs to obtain equipment for the production of the microphone for the key board. Because of the required sensitivity of the microphone and its small size, the company needs specialized equipment for production. Lucas Johnson, the company president, has found a vendor for the equipment. Memtech Acoustical Equipment has offered to sell Advanced...
Advanced Computers has decided to proceed with the manufacture and distribution of the virtual keyboard (VK)...
Advanced Computers has decided to proceed with the manufacture and distribution of the virtual keyboard (VK) the company has developed. To undertake this venture, the company needs to obtain equipment for the production of the microphone for the key board. Because of the required sensitivity of the microphone and its small size, the company needs specialized equipment for production. Lucas Johnson, the company president, has found a vendor for the equipment. Memtech Acoustical Equipment has offered to sell Advanced Computers...
Advanced Computers has decided to proceed with the manufacture and distribution of the virtual keyboard (VK)...
Advanced Computers has decided to proceed with the manufacture and distribution of the virtual keyboard (VK) the company has developed. To undertake this venture, the company needs to obtain equipment for the production of the microphone for the key board. Because of the required sensitivity of the microphone and its small size, the company needs specialized equipment for production. Lucas Johnson, the company president, has found a vendor for the equipment. Memtech Acoustical Equipment has offered to sell Advanced Computers...
You and your closest friends have decided to go to see a private screening of a...
You and your closest friends have decided to go to see a private screening of a movie at a local movie theater where you can be socially distant. Friends will be added to the queue after their names are input by the user. Because of current restrictions, the queue (line) for tickets can only have a capacity of 7 people. Write a Java program using a Queue (of size 7) that will display a menu: 1) add person to line...
. Mayflower Co. has recently decided to go public and has hired you as an independent...
. Mayflower Co. has recently decided to go public and has hired you as an independent CPA. One statement that the enterprise is anxious to have prepared is a statement of cash flows. Financial statements of Mayflower for 2019 and 2018 are provided below. BALANCE SHEETS                                                                                                  12/31/19                            12/31/18 Cash                                                                                       $408,000                          $ 192,000 Accounts receivable                                                                 360,000                             216,000 Inventory                                                                                   384,000                             480,000 Property, plant and equipment                          $608,000                           $960,000 Less accumulated depreciation                        (320,000)    288,000      (304,000)     656,000                                                                                              $1,440,000                        $1,544,000 Accounts payable                                                                  $ 176,000                         ...
You have decided to go into the goat feed business. You’ve been mixing it for your...
You have decided to go into the goat feed business. You’ve been mixing it for your own goats and now neighbors and friends want the same mix. So you need to sit down and do a little economics to figure out whether this is a profit opportunity or not. The production function for your special mix of feed is:                                     Y = X11/2 X21/4 Where Y = lbs of feed mix X1 = lbs. of oats X2 = lbs. of...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT