Question

In: Computer Science

An alien spaceship has landed in your backyard full of various types of aliens. They all...

An alien spaceship has landed in your backyard full of various types of aliens. They all are saying “I come in peace”,
but you’re not so sure. You consult your
trusty guide to alien encounters to find out
that that there are three criteria that
determine if an alien is telling the truth:
number of heads, type of weapon and
intensity of their eyes.
 Friendly features: squirt gun as weapon
 Unfriendly features: weapon (as long as it’s
not a squirt gun), beady eyes, more than two
heads

 Don’t ask about the type of weapon if you know the alien does not have a weapon
 If an alien has two or more unfriendly features he is unfriendly
o So beady eyes, three heads, but no weapon & the alien is an enemy
o So squirt gun, regardless of other features, the alien is friendly

Pseudocode (10 points)
 Create the document in using Microsoft Office Word or Power Point or the Open Office equivalent, as
long as I am able to open it.
 Start with a pseudocode. Write the pseudocode in English, step by step what you need to do to solve the
problem. There are many ways this can be done. Take your time and think about it.
 No flowchart is required, but you can certainly draw one if it helps you.
 put your name, date, section, and description of the program at the top of the page.
 save the file lastname_ch3AlienPseudocode

Solutions

Expert Solution

The program will perform the below checks in order to solve the problem.

  1. Once the alien is found, weapon check will be performed. If Alien is without weapon OR having a squirt gun , it will not be counted as enemy feature for the alien.
  2. The alien can have below unfriendly feature:
  1. Weapon other than squirt gun
  2. Beady eyes
  3. More than two heads
  1. An alien will be enemy if any two or all three of the above unfriendly features are found in it.

The complete Pseudocode to solve the problem is given as below along with the detailed explanation in next section:

----------------------------------------------------------------------------------------------------

START:

Set : enemyfeature = 0 //Set the unfriendly feature to 0 in starting of the program.

IF: Alien has weapon // check if the alien is having weapon

           Then: Check the weapon type   //If weapon is available, check the weapon type

                   If weapon is other than Squirt Gun, set enemyfeature = 1;

          Else: It does not have enemy weapon

ENDIF;

IF: Alien has beady eyes:

          Then: Increase the emeyfeature counter

Else IF: Alien has more than two heads:

          Then: Increate the enemyfeature counter

Else:

                             Keep the enemyfeature value same.

ENDIF;

//Let’s check the final feature count for alien and get the result

IF: enemyfeature counter >= 2 //if 2 or more enemy features are true

          Then: Alien is an enemy.

          Else: Alien is friendly.

ENDIF

END Program

         

----------------------------------------------------------------------------------------------------

Explanation of pseudocode for a better understanding:

The Pseudocode is explained in 4 steps

  1. To keep records for the count of unfriendly feature in the enemy, enemyfeature counter variable is used.

Set : enemyfeature = 0

  1. First IF statement will check if the weapon is available with the Alien. If it is available and other than Squirt Gun, enemyfeature will get increased by 1.

IF: Alien has weapon // check if the alien is having weapon

           Then: Check the weapon type   //If weapon is available, check the weapon type

                   If weapon is other than Squirt Gun, set enemyfeature = 1;

          Else: It does not have enemy weapon

ENDIF;

  1. Other two unfriendly features will be checked in the below section of pseudocode and enemyfeature counter will get increased by 1 if any of the feature is available in the alien. If both of the features are found in the enemy, the enemyfeature will increase by 2.

IF: Alien has beady eyes:

     Then: Increase the emeyfeature counter

Else IF: Alien has more than two heads:

               Then: Increate the enemyfeature counter

Else:

                        Keep the enemyfeature value same.

ENDIF;

  1. At the end of the code, value of enemyfeature will be checked. If it is more than 2, the alien will be declared as enemy alien.

IF: enemyfeature counter >= 2 //if 2 or more enemy features are true

     Then: Alien is an enemy.

     Else: Alien is friendly.

ENDIF

----------------------------------------------------------------------------------------

Please let me know if more clarification is required.


Related Solutions

The human body has various types of muscle. Describe how the various muscle types (i.e. skeletal,...
The human body has various types of muscle. Describe how the various muscle types (i.e. skeletal, cardiac, and smooth) contribute to the efficiency of a road cyclist. In this discussion, please include the location of each of the various muscle types in the body. If the muscle type is found in multiple areas in the body, focus on the areas most relevant for this type of exercise
The surface water in your backyard pong has a pH=7.7 and its chemistry is dominated by...
The surface water in your backyard pong has a pH=7.7 and its chemistry is dominated by the carbonate system. For the carbonate system, a pKa1=6.35 and a pKa2=10.33 give important information about the equilibrium condition of the carbonate system at various pH values. a. Which carbonate species ([H2CO3], [HCO3-], and [CO3-2] would you expect to be the dominate species? Why? b. The pond is not equilibrated with the atmosphere at pH=7.7. What changes will take place if the water equilibrates...
Sampling Distribution show all your work for full point. A bank in a small town has...
Sampling Distribution show all your work for full point. A bank in a small town has 100,000 customers. A national survey on the banking habits of people in U.S. shows that 80% of the people with income higher than 75,000 dollars have both savings and checking accounts and also shows that the average number of banking operations that a person aged 18 and over performs per week is 10. The manager of the bank decides to do a survey among...
Your spaceship has docked at a space station above Mars. The temperature inside the space station...
Your spaceship has docked at a space station above Mars. The temperature inside the space station is a carefully controlled 24 ∘C at a pressure of 735 mmHg . A balloon with a volume of 515 mL drifts into the airlock where the temperature is -83 ∘C and the pressure is 0.120 atm . What is the final volume, in milliliters, of the balloon if n remains constant and the balloon is very elastic?
Question 5 There are various types of IT systems which come in all shapes and sizes....
Question 5 There are various types of IT systems which come in all shapes and sizes. They are categorised to assist us in evaluating the appropriateness of their handling of business risk. List the five types of system and describe each system. (20)
Your firm has just landed a large client contract in Germany and secured an even larger...
Your firm has just landed a large client contract in Germany and secured an even larger supplier contract from Mexico. You are in the automobile stereo sound system business with the Detroit Auto Show, your signature event (product, advertising, etc.), and a potential deal with the Chinese and Brazilians projected to be signed and sourced in March and July 2016, respectively. What do you recommend your C-Suite consider and your risk management group do, if anything, about this increasingly international...
All businesses are subject to various types of legal proceedings. Merck & Co. Inc., a global...
All businesses are subject to various types of legal proceedings. Merck & Co. Inc., a global health care company that manufacturers prescription medicines, has been a defendant in a number of product liability lawsuits. In the notes to Merck’s 2012 financial statements, the company states: “There are various other pending legal proceedings involving the Company, principally product liability and intellectual property lawsuits. While it is not feasible to predict the outcome of such proceedings, in the opinion of the Company,...
Problem 5. (8 points) Suppose you find $500 buried in your backyard and thus has been...
Problem 5. (8 points) Suppose you find $500 buried in your backyard and thus has been out of circulation. Explain what happens to M1 and M2 when you put $200 in your checking account, $200 in your money market mutual fund, and $100 in your savings account.
After graduation, you landed a job at a large, multinational media corporation. Your firm has been...
After graduation, you landed a job at a large, multinational media corporation. Your firm has been negotiating a license agreement to use a certain documentary film for a term of 2.5 years. You expect that the film will return cash flows of $2.5 million at the end of each six-month period. The company licensing the rights to use the film is asking $12.5 million. Both you and your boss LOVE this documentary film and feel that the film should be...
All types of social work assessments are equally good. Answer in 5 full sentences whether you...
All types of social work assessments are equally good. Answer in 5 full sentences whether you Agree or disagree.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT