1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
NISA [10]
3 years ago
5

The Zootopia Police Department is recruiting new officers and has come up with an innovative equation to hire. They define hireS

core as a weighted sum of agility and strength.hireScore = 1.8 * agility + 2.16 * strength + 3.24 * speedThe candidates for this hiring season are foxes, bunnies and sloths. Chief Bogo has requested you to write a program that takes in these attributes and produces an hireScore for the candidate.The program should provide a menu to choose the anthropomorphic animal. The menu should have the___________.
A. FoxB. BunnyC. SlothD. Quit
Computers and Technology
1 answer:
Dahasolnce [82]3 years ago
3 0

Answer:

#include<iostream>

#include<limits>

#include<iomanip>

using namespace std;

//function that returns true

//if there is invalid input like giving string as input

// for integer value.

bool isInvalidInput()

{

  //return true if cin.fail

  if(cin.fail())

  {

      //clear the buffer

      cin.clear();

      cin.ignore(numeric_limits<streamsize>::max(),'\n');

      return true;

  }

  return false;

}

//function that calculates the hire score for given 3 parameters.

double calHireScore(double agility,double strength,double speed)

{

  return (1.8*agility) + (2.16 * strength) + (3.24 * speed);

}

//calculate hire score for fox.

void calFoxHireScore()

{

  double agility,strength;

 

  cout<<"Enter Agility Value: ";

  //get agility as input and validate it.

  cin >> agility;

  if(isInvalidInput() || agility <= 0)

  {

      cout<<"\nError: Agility value must be > 0"<<endl;

      return;

  }

 

  cout<<"Enter Strength Value: ";

  cin >> strength;

  if(isInvalidInput() || strength <= 0)

  {

      cout<<"\nError: Strength value must be > 0"<<endl;

      return;

  }

 

  cout<<"\nHire Score for Fox: "<<calHireScore(agility,strength,0)<<endl;

}

//function that asks input from user for

//calculating hire score for Sloth.

void calSlothHireScore()

{

  double strength,speed;

 

  cout<<"Enter Strength Value: ";

  cin >> strength;

  if(isInvalidInput() || strength <= 0)

  {

      cout<<"\nError: Strength value must be > 0"<<endl;

      return;

  }

 

  cout<<"Enter Speed Value: ";

  cin >> speed;

  if(isInvalidInput() || speed <= 0)

  {

      cout<<"\nError: Speed value must be > 0"<<endl;

      return;

  }

 

  cout<<"\nHire Score for Sloth: "<<calHireScore(0,strength,speed)<<endl;

}

//function that asks input from user for

//calculating hire score for Bunny.

void calBunnyHireScore()

{

  double agility,speed;

 

  cout<<"Enter Agility Value: ";

  cin >> agility;

  if(isInvalidInput() || agility <= 0)

  {

      cout<<"\nError: Agility value must be > 0"<<endl;

      return;

  }

 

  cout<<"Enter Speed Value: ";

  cin >> speed;

  if(isInvalidInput() || speed <= 0)

  {

      cout<<"\nError: Speed value must be > 0"<<endl;

      return;

  }

 

  cout<<"\nHire Score for Bunny: "<<calHireScore(agility,0,speed)<<endl;

}

//function to display menu for user.

void menu()

{

  cout<<"\n1. Fox"<<endl;

  cout<<"2. Bunny"<<endl;

  cout<<"3. Sloth"<<endl;

  cout<<"0. Quit"<<endl;

  cout<<"Enter your choice: ";

}

//main method

int main()

{

  int choice;

  do

  {

      //asks choice

      menu();

      cin >> choice;

      //if invalid input print erro message

      if(isInvalidInput())

      {

          cout<<"\nError: Invalid choice enetered. Try Again\n";

      }

      else

      {

          cout<<"\n";

          //if any one of the choices do accordingly

          //for invalid choice print error mesage.

          switch(choice)

          {

              case 1:

                  calFoxHireScore();

                  break;

              case 2:

                  calBunnyHireScore();

                  break;

              case 3:

                  calSlothHireScore();

                  break;

              case 0:

                  cout<<"\nQutting...\n";

                  break;

              default:

                  cout<<"Invalid choice entered."<<endl;

                  break;

          }

      }

     

  }while(choice != 0);

 

  return 0;

}

Explanation:

You might be interested in
An asymmetric encryption system utilizes how many keys?
ivanzaharov [21]
Two. One for encryption, and one for decryption. RSA is an example of an asymmetric encryption algorithm.
7 0
3 years ago
The case states that google intended the limited initial rollout to be a beta test of google glass, meaning that the adopters we
tigry1 [53]

Google intended the limited initial rollout to be a test of google glass, that the adopters were Innovators. The initial rollout of Google Glass was limited, purposefully so as to set the price very high. This mean that only a selected few, and those with plenty of disposable income, would be the first to use these devices. Google required people to register for the chance to receive a set. Even if many would want to spend the money on these devices, Google allowed only a selected few to receive them.

7 0
3 years ago
Dr. Wisteria is a prominent chiropractor in the Chicago area. She wants to provide a forum for her patients to discuss their hea
Svet_ta [14]

The best-suited telecommunications tool for Dr. Wisteria is a blog.

a blog

<u>Explanation:</u>

A blog can be defined as an informational website and more a platform for exchanging views and ideas about a particular topic.

There are various blogging platforms available. Dr. Wisteria should start writing blogs about health issues and in this way, she would be able to interact with all the people accessing the blog. People can also post their queries about their health issues and Dr. Wisteria can always reply to them.

This would also create a lot of awareness about any particular health issue being discussed as it is not necessary that only those people who want to post something will access the blog post, it can always be accessed by anyone.

5 0
2 years ago
Read 2 more answers
What's an array in computer science
muminat

Answer:

An array is a series of memory locations – or 'boxes' – each of which holds a single item of data, but with each box sharing the same name. All data in an array must be of the same data type.

6 0
3 years ago
Explain how electric power and electrical energy are related
AlladinOne [14]

Electric power and electrical energy are related because electrical energy comes from electrical power. If one comes from the other, they are related. Hope this helps!

3 0
3 years ago
Read 2 more answers
Other questions:
  • *asap* Name one of the similarities between Word and Excel.
    7·1 answer
  • What is the difference between Google and a subject directory like Yahoo Directory or Infomine?
    14·2 answers
  • A mother calls you to report that her 15-year-old daughter has run away from home. She has access to her daughter's e-mail accou
    6·2 answers
  • Meg wants to preview all images in a folder so that she can quickly find the image she wants. Which view will help her do this?
    13·2 answers
  • It is an island country; it fought against us in World War II; it is known for sushi.
    14·2 answers
  • Generalized goals are more likely to be achieved than specific goals. True or False
    7·1 answer
  • You need to install Windows on a new computer. You also need to replace a motherboard in another computer, and both tasks need t
    14·2 answers
  • 1.
    7·1 answer
  • Why does my smoke detector keep beeping even after i change the battery?.
    14·1 answer
  • 4.8% complete this is a single choice question; skip ahead to question content a b c d confirm difficulty level: moderate an int
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!