Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update sortinghat.cpp #68

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
168 changes: 73 additions & 95 deletions 3-conditionals-and-logic/harry-potter-sorting-hat/sortinghat.cpp
Original file line number Diff line number Diff line change
@@ -1,153 +1,131 @@
// Project Case C++ (Sorting Hat Program Harry Potter)
#include <iostream>

int main() {

int main (){
// declare & initialize 4 varible to receive point
int gryffindor = 0;
int hufflepuff = 0;
int ravenclaw = 0;
int slytherin = 0;

// declare 4 answer variable to store their anwer for question
int answer1, answer2, answer3, answer4;

std::cout << "===============\n";
std::cout << "The Sorting Hat\n";
std::cout << "===============\n\n";

// ~~~~~~~~~~ Question 1 ~~~~~~~~~~

std::cout << "Q1) When I'm dead, I want people to remember me as:\n\n";

std::cout << " 1) The Good\n";
std::cout << " 2) The Great\n";
std::cout << " 3) The Wise\n";
std::cout << " 4) The Bold\n\n";

std::cout << "Enter your answer (1-4): ";
std::cout << "=========================\n";
std::cout << "The sorting Hat Quiz \n";
std::cout << "=========================\n";

// make instrument for question3
std::cout << "Q1) When I'm dead, I want people to remember me as :\n";
std::cout << "1) The Good \n";
std::cout << "2) The Great \n";
std::cout << "3) The Wise \n";
std::cout << "4) The Bold \n";
std::cout << "Answer Q1) : " ;
std::cin >> answer1;
std::cout << "\n";

if (answer1 == 1)
// Make conditional logic decision for answer1
if (answer1 == 1){
hufflepuff++;
else if (answer1 == 2)
} else if (answer1 == 2){
slytherin++;
else if (answer1 == 3)
} else if (answer1 == 3){
ravenclaw++;
else if (answer1 == 4)
} else if (answer1 == 4){
gryffindor++;
} else {
std::cout << "Invalid input \n";
}

// ~~~~~~~~~~ Question 2 ~~~~~~~~~~

std::cout << "\nQ2) Dawn or Dusk?\n\n";

std::cout << " 1) Dawn\n";
std::cout << " 2) Dusk\n\n";

std::cout << "Enter your answer (1-2): ";
// Make instrument for question 2
std::cout << "Q2) Dawn or Dusk \n";
std::cout << "1) Dawn\n";
std::cout << "2) Dusk\n";
std::cout << "Answer Q2) : ";
std::cin >> answer2;
std::cout << "\n";

if (answer2 == 1)
{

// Make conditional logic decision for answer2
if (answer2 == 1){
gryffindor++;
ravenclaw++;

}
else if (answer2 == 2)
{

} else if (answer2 == 2){
hufflepuff++;
slytherin++;

} else {
std::cout << "Invalid input \n";
}
else
{

std::cout << "Invalid input\n";

}

// ~~~~~~~~~~ Question 3 ~~~~~~~~~~

std::cout << "\nQ3) Which kind of instrument most pleases your ear?\n\n";

std::cout << " 1) The violin\n";
std::cout << " 2) The trumpet\n";
std::cout << " 3) The piano\n";
std::cout << " 4) The drum\n\n";

std::cout << "Enter your answer (1-4): ";
// Make something for question3
std::cout << "Q3) Which kind of instrument most pleases your ear? \n";
std::cout << "1) The violin \n";
std::cout << "2) The trumpet \n";
std::cout << "3) The piano \n";
std::cout << "4) The drum \n";
std::cout << "Answer Q3 : \n";
std::cin >> answer3;
std::cout << "\n";

if (answer3 == 1)
// Make conditional logic decision3 for answer3
if(answer3 == 1){
slytherin++;
else if (answer3 == 2)
} else if (answer3 == 2){
hufflepuff++;
else if (answer3 == 3)
} else if (answer3 == 3){
ravenclaw++;
else if (answer3 == 4)
} else if (answer3 == 4){
gryffindor++;
} else {
std::cout << "Invalid input \n";
}

// ~~~~~~~~~~ Question 4 ~~~~~~~~~~

std::cout << "\nQ4) Which road tempts you the most?\n\n";

std::cout << " 1) The wide, sunny grassy lane\n";
std::cout << " 2) The narrow, dark, lantern-lit alley\n";
std::cout << " 3) The twisting, leaf-strewn path through woods\n";
std::cout << " 4) The cobbled street lined (ancient buildings)\n\n";

std::cout << "Enter your answer (1-4): ";
std::cin >> answer4;
// Make something for question 4
std::cout << "Q4) Which road tempts you most?\n";
std::cout << "1) The wide, sunny grassy lane \n";
std::cout << "2) The narrow, dark, lantern-litalley \n";
std::cout << "3) The twisting, leaf-strewn path through woods \n";
std::cout << "4) The cobbled street lined (ancient buildings) \n";
std::cout << "\n";

if (answer4 == 1)
// make conditional logic decision4 answer4
if (answer4 == 1){
hufflepuff++;
else if (answer4 == 2)
} else if (answer4 == 2){
slytherin++;
else if (answer4 == 3)
} else if (answer4 == 3){
gryffindor++;
else if (answer4 == 4)
ravenclaw++;

// ========== Sorting ==========

std::cout << "\nCongrats on being sorted into... ";
} else {
std::cout << "Invalid input \n";
}

// Find out which if the four houses has heigh answer
int max = 0;
std::string house;

if (gryffindor > max)
{

// Make a logical conditional to find maximum
if (gryffindor > max){
max = gryffindor;
house = "Gryffindor";

}

if (hufflepuff > max)
{

if (hufflepuff > max){
max = hufflepuff;
house = "Hufflepuff";

}

if (ravenclaw > max)
{

if (ravenclaw > max){
max = ravenclaw;
house = "Ravenclaw";

}

if (slytherin > max)
{

if (slytherin > max){
max = slytherin;
house = "Slytherin";

}

std::cout << house << "!\n";
std::cout << "Thank You For Your attention \n";

return 0;

return 0;
}