Question: C++ Write an algorithm for a Sorting Hat that returns H, R, S, or G based on the following criteria. The properties for a student

C++

Write an algorithm for a Sorting Hat that returns H, R, S, or G based on the following criteria. The properties for a student being Sorted are Intelligence, Bravery, Dependability, and Ambition. These are abbreviated mI, mB, mD, and mA.

If a student's Intelligence is their highest stat, return R unless their Ambition is at least twice their Dependability in which case return S. If Bravery is their highest stat, return G. If Dependability and Ambition together add up to more than Intelligence and Bravery together, return S. If Intelligence is the lowest stat, return G unless Dependability is greater than Ambition, which would return H. If none of these apply, return S if Dependability is lowest, and H otherwise.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!