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
In Google search results, how are organic links different from sponsored links?
xxMikexx [17]
Sponsored links are links that have been paid for in order to bring them to the first positions when the engine returns the results of the search.  Organic links are links that have not been paid for.  Your answer is D.
4 0
3 years ago
Read 2 more answers
What is the body of scientific knowledge based on?
ANTONII [103]
It depend on all such as guess ,observation ,hypothesis and etc
3 0
2 years ago
Read 2 more answers
The following is a sequence of undo-log records written by two transactions T and U: &lt; START T&gt;; ; &lt; START U&gt;; ; ; ;
tatiyna

Answer:

Giving that: The following is a sequence of undo-log records written by 2 transactions T and U:

< START T >;

< T,A,10 >;

< START U >;

< U, B, 20 >;

< T, C, 30 >;

< U, D, 40 >;

< Commit U >;

< T, E, 50 >;

< Commit T >;

1. < START U >

      Recovery action in this case will be undo(-1) and undo(0). All restored to its original Value

     log records < T, A, 10 >,  < T, abort >; as written out

2. < T, E, 50 >

      Recovery action in this case will be undo(8) and redo(0). A and C is restored to its original value, B and D are set to 20 and 40

      log records <T, C, 30 >,  < T, A, 10 >,  < T, abort >  are written out

3. < Commit T >

      Recovery action in this case will be redo(7) and redo(4). A and C are set to 10 and 30, B and D are set to 20 and 40

7 0
3 years ago
What will be the results from running the following code?
kari74 [83]

Answer:syntax error

Explanation:

Correct on edg 2021

4 0
2 years ago
What three files do you need to perform a mail merge?<br><br> HELP ASAP PLEASE!!
Burka [1]

The 3 files you need to have for a successful mail merge are:

  • An Excel spreadsheet works
  • Outlook Contact List.
  • Apple Contacts List or Text file, etc.

<h3>What is Mail Merge?</h3>

This is known to be the act of carrying out  a Mail Merge and it is one where a person will need to use a Word document and a recipient list, that is an Excel workbook.

Files needed are:

  • Text file,
  • address files, etc.

The 3 files you need to have for a successful mail merge are:

An Excel spreadsheet worksOutlook Contact List.

Apple Contacts List or Text file, etc.

Learn more about mail merge from

brainly.com/question/20904639

#SPJ1

4 0
1 year ago
Other questions:
  • You are tasked with setting up an employee’s computer.Instead of a new computer,she will be using a computer with an older opera
    11·2 answers
  • Which option should you select to ignore all tracked changes in a document
    6·1 answer
  • What are the 7 basic components found in a computer tower
    5·2 answers
  • Which of the following devices is used to connect a computer to a network
    7·1 answer
  • Which player type focuses on level progression?
    13·1 answer
  • Who would use a CLI? (Command Line Interface)
    9·1 answer
  • In a car crash, wearing a seat belt __________________.
    5·2 answers
  • Write a program that uses nested loop or for statements to display Pattern A below, followed by an empty line and then another s
    5·1 answer
  • How will the health care professions be affected by all the computerized and technical advances concerning disabilities?
    9·1 answer
  • The function below takes two arguments: a string (name) and an integer (position). Complete the function so that it prints out t
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!