tea
cup
cups
vodka
shot
shots
beer
bottle
bottles
The if statement that I used to not allow the users to input wrong things doesn't work. Can someone please help? thanks
#include "stdafx.h"
#include <fstream>
#include <iomanip>
#include <iostream>
#include <string>
using namespace std;
int main()
{
string input_file_name;
string beverage;
string container_sing ;
string container_plur ;
ifstream input_stream;
int choice;
int count=1;
cout << "Please enter the input's file name: ";
getline(cin, input_file_name, '\n');
input_stream.open(input_file_name.c_str());
if(!input_stream.good())
{
cout << "We failed to open " << input_file_name << endl;
cout << "Goodbye!" << endl;
system("pause");
return 1;
}
cout<<"Please pick what you want for the drink, where 1 is tea, 4 is vodka, 7 is beer"<<endl;
cin>>choice;
if((choice!=1)&&(choice!=4)&&(choice!=7)){
cout<<"Sorry you entered a bad input please try again ."<<endl;
cin.clear();
cin>>choice;
}
while(count < choice && getline(input_stream, beverage ) )
count++;
getline(input_stream, beverage);
getline(input_stream,container_sing);
getline(input_stream,container_plur);
for(int bottles=99; bottles>1; --bottles)
{
cout << bottles <<" "<< container_plur<<" of "<<beverage<< " on the wall," << endl;
cout << bottles <<" "<< container_plur<<" of "<<beverage<<"," << endl;
cout << "Take 1 down pass it around" << endl;
cout << --bottles <<" " << container_plur<<" of " <<beverage<< " on the wall\n" << endl;
}
cout<< "1 " <<container_sing<<" of " <<beverage<< " on the wall,"<<endl;
cout<< "1 " <<container_sing<< " of " <<beverage<<","<<endl;
cout<<"Take it down and pass it around"<<endl;
cout<<"No " <<container_plur<< " of "<<beverage<<" on the wall\n"<<endl;
input_stream.close();
system("pause");
return 0;
}

New Topic/Question
Reply



MultiQuote




|