C++ "Vending Machine" task
Do not use namespace std;
Put your code into functions if possible. For example the Question for the user should be a single function.

void printOptions() {
     std::cout &lt;&lt; "Your choices of drinks are: " &lt;&lt; "\n";
     std::cout &lt;&lt; "1 - Coke" &lt;&lt; "\n";
     std::cout &lt;&lt; "2 - Sprite" &lt;&lt; "\n";
     std::cout &lt;&lt; "3 - Water" &lt;&lt; "\n";
     std::cout &lt;&lt; "4 - Orange Juice" &lt;&lt; "\n";
     std::cout &lt;&lt; "5 - Apple Juice" &lt;&lt; "\n";
     std::cout &lt;&lt; "What drink would you like (1/5): ";


}

Note that i use "\n" instead of std::endl as this doesnt flush the stream.
Use a dedicated input function

int chooseBeverage() {
    int beverage;
    std::cin &gt;&gt; beverage;
    return beverage;
}

Now define a function that takes the choice and give the beverage.

enum choice {
    NONE = 0;
    COKE,
    SPRITE,
    WATER,
    ORANGE_JUICE,
    APPLE_JUICE
};

void serveBeverageIf(choice beverage) {
     if(beverage == COKE)
        std::cout &lt;&lt; "You chose Coke." &lt;&lt; "\n";
     else if(beverage == SPRITE)
        std::cout &lt;&lt; "You chose Sprite." &lt;&lt; "\n";
     else if(beverage == WATER)
        std::cout &lt;&lt; "You chose Water." &lt;&lt; "\n";
     else if(beverage == ORANGE_JUICE)
        std::cout &lt;&lt; "You chose Orange Juice." &lt;&lt; "\n";
     else if(beverage == APPLE_JUICE)
        std::cout &lt;&lt; "You chose Apple juice." &lt;&lt; "\n";
     else
        std::cout &lt;&lt; "Error. choice was not valid, here is your money back.";
 }

 void serveBeverageSwitch(choice beverage) {
     switch(beverage)
     case COKE:
        std::cout &lt;&lt; "You chose Coke." &lt;&lt; "\n";
        break;
     case SPRITE:
        std::cout &lt;&lt; "You chose Sprite." &lt;&lt; "\n";
        break;
     case WATER:                
        std::cout &lt;&lt; "You chose Water." &lt;&lt; "\n";
        break;
     case ORANGE_JUICE:                
        std::cout &lt;&lt; "You chose Orange Juice." &lt;&lt; "\n";
        break;
     case APPLE_JUICE:                
        std::cout &lt;&lt; "You chose Apple juice." &lt;&lt; "\n";
        break;
     default:
        std::cout &lt;&lt; "Error. choice was not valid, here is your money back.";
        break;
     }
 }

What you could also do is use a third option utilizing a map.

void serveBeverageMap(choice beverage) {
map&lt;choice, std::string&gt; nameMap = {
    std::make_pair(COKE, "Coke"),
    std::make_pair(SPRITE, "Sprite"),
    std::make_pair(WATER, "Water"),
    std::make_pair(ORANGE_JUICE, "Orange juice"),
    std::make_pair(APPLE_JUICE, "Apple juice")            
};
if(nameMap.find(beverage) == nameMap.end()) {
   std::cout &lt;&lt; "Error. choice was not valid, here is your money back.";
} else { 
    std::cout &lt;&lt; You chose " &lt;&lt; nameMap[beverage] &lt;&lt; ".";
}
}