WSQ#9, MT 19,21

--Originally published at TC1017 Programing Curse

This homework ask me to create a program that prints something that is in a .txt, it was a little difficult to understand how to do it but at the end after investigate it was actually easy

and also here we can see Mastery Topic 19, and 21

#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int main()
{
string game, name;
cout<<“Tell me which game do you want to know its history “<<endl;
cout<< “(FallOut, Borderlands, Doom)”<<endl;
cin>>name;
if (name==”FallOut”){
ifstream file(“FallOut.txt”);
if(file.is_open())
{
while(getline(file,game))
cout<<game<<endl;
}
file.close();
}
else
{
cout<<“Try Later “<<endl;
}
}
else{
if(name==”Borderlands”){
ifstream file(“Borderlands.txt”);
if(file.is_open())
{
while(getline(file,game))
{
cout<<game<<endl;
}
file.close();
}
else
{
cout<<“Try Later”<<endl;
}
}
else{
if(name==”Doom”){
ifstream file(“Doom.txt”);
if(file.is_open())
{
while(getline(file,game))
{
cout<<game<<endl;
}
file.close();
}
else
{
cout<<“Try Later”<<endl;
}
}
}
}
return 0;
}

i just have to convert this into a fucntion.

WSQ9.PNGWSQ9.1.PNG

Resultado de imagen para fall out game

image taken from: http://kotaku.com/lets-rank-the-fallout-games-best-to-worst-611408965