Hello I have made a program that outputs a menu where you can do different things, it does kinda what I want it to do put it feel like you could simplify it somehow. I am new to programming so if someone has any good tip I would aprecciate it!
Here is the code:
Code:
#include <iostream>
#include <string>
using namespace std;
int main()
{
int j;
string proceed;
do
{
cout << "Here are a list of different choices:\n";
cout << "\t1. Bajs\n";
cout << "\t2. Kiss\n";
cout << "\t3. Neger\n";
cout << "\t4. Beer song\n";
cout << "\t0. Quit\n";
cout << "\nPlease enter one of the number from the list: ";
cin >> j;
cout << '\n';
if ( j == 1 )
{
cout << "You are a bajskorv!\n";
}
else if ( j == 2 )
{
cout << "You like to kissa!\n";
}
if ( j == 3 )
{
cout << "You are a black independent woman!\n";
}
else if ( j == 4 )
{
for ( int i = 99; i >= 0; i-- )
{
if ( i == 1 )
{
cout << i << " bottle of beer on the wall, " << i << " bottle of beer.\n";
cout << "Take one down and pass it around, no more bottles of beer on the wall.\n";
continue;
}
if ( i != 0 )
{
cout << i << " bottles of beer on the wall, " << i << " bottles of beer.\n";
cout << "Take one down and pass it around, " << i - 1 << " bottles of beer on the wall.\n";
cout << '\n';
}
if ( i == 0 )
{
cout << '\n';
cout << "No more bottles of beer on the wall, no more bottles of bear\n";
cout << "Go to the store and buy some more, 99 bottles of beer on the wall.\n";
}
}
}
if ( j != 1 && j != 2 && j != 3 && j != 4 && j != 0 )
{
cout << "Not a valid option, please choose a correct number from the list!";
}
if ( j == 0 )
{
return 0;
}
cout << "\n\n";
cout << "Do you want to choose another number?\n";
cout << "y or n: ";
cin >> proceed;
if ( proceed == "n" || proceed == "N" )
{
cout << "Thank you, come again\n";
return 0;
}
else if ( proceed == "y" || proceed == "Y" )
{
cout << "Here you see the list again:\n\n";
}
if ( proceed != "y" || proceed != "Y" || proceed != "n" || proceed != "N" )
{
int k = 0;
while ( k == 0)
{
cout << "Not an option, try again!\n\n";
cout << "Choose one of the following:s\n";
cout << "y or n: ";
cin >> proceed;
if ( proceed == "n" || proceed == "N" )
{
cout << "Thank you, come again\n";
return 0;
}
else if ( proceed == "y" || proceed == "Y" )
{
cout << "Here you see the list again:\n\n";
}
}
}
}
while ( true );
}