Skip to content

Instantly share code, notes, and snippets.

@mattsegura
Created December 4, 2020 08:21
Show Gist options
  • Save mattsegura/e7d64bf21b59ad92c3d7dba2f156884f to your computer and use it in GitHub Desktop.
Save mattsegura/e7d64bf21b59ad92c3d7dba2f156884f to your computer and use it in GitHub Desktop.
simple else if statement utilizing a menu system
#include <iostream>
using namespace std;
int main()
{
int books, points, month;
cout << "How many books have you purchased this semester?\n";
cin >> books;
if (books == 0)
{
cout << "You earn 0 points";
}
else if (books == 1)
{
cout << "You earn 5 points";
}
else if (books == 2)
{
cout << "You earn 15 points";
}
else if (books == 3)
{
cout << "You earn 30 points";
}
else if (books >= 4)
{
cout << "You earn 60 points";
}
else
{
cout << "Wrong input, please choose the right number\n";
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment