The sentences should begin with a capital letter and end with a period.
scroll all the way down to void Create_Story() // Option 4 Thats where I'm trying to make the first letter a capital letter.
Code:
#include <iostream>
#include <iomanip>
#include <string>
#include <cctype> //Using (toupper) function to convert low case letter to upper case
#include "sentence.h"//adding a header file to the program
using namespace std;
void Word_List();
void Change_Words();
void Write_Sentence();
void Create_Story();
int Sentence(int x);// Function prothotype.
//Array declarations as global variables
string Articles [5] = {"a", "the" ,"one" , "some" ,"any" };
string Nouns [5] = {"man", "tree" ,"dog" , "car" ,"town" };
string Verbs [5] = {"drove","jumped", "ran" ,"walked" , "threw"};
string Prepositions [5] = {"to","from", "over" ,"under" , "through"};
int i, x, Number;
string Replace;
int main()
{
char selection;
do
{
system("cls");
cout << " Story simulation Program [[ Dilmer Valecillos CS1600-001 ]] " << endl;
cout << " \n Main Menu\n"
<< " ---- ----\n"
<< " 1 <- Show word lists \n"
<< " 2 <- Change words \n"
<< " 3 <- Write a sentence \n"
<< " 4 <- Write a story \n"
<< " 5 <- Quit\n\n"
<< " Choice: ";
//Get menu selection
selection = cin.get();
//Process selection
switch( selection)
{
case '\n':
break;
case '1': Word_List();
break;
case '2': Change_Words();
break;
case '3': Write_Sentence();
break;
case '4': Create_Story();
break;
case '5':
break;
default: cout << '\a';
}
}
while( selection != '5' );
return 0;
}
void Word_List() //Option 1
{
system("cls");
char selection;
do
{
system("cls"); // Clear the screen
cout <<"\n\n Word Lists\n\n"
<<" 1 <- Article\n"
<<" 2 <- Nouns\n"
<<" 3 <- Verbs\n"
<<" 4 <- Prepositions\n"
<<" 5 <- Return to Main Menu\n\n"
<< " Choice : ";
cin.get(selection);
switch (selection)
{
case '1':
system("cls");
cout << "\n\n";
cout << " Articles\n";
for (i = 0; i < 5; i++)
{
cout << " " << i << ". " << Articles [i] << endl;
}
system("pause");
break;
case '2':
system("cls");
cout << "\n\n";
cout << " Nouns\n";
for (i = 0; i < 5; i++)
{
cout << " " << i << ". " << Nouns [i] << endl;
}
system("pause");
break;
case '3':
system("cls");
cout << "\n\n";
cout << " Verbs\n";
for (i = 0; i < 5; i++)
{
cout << " " << i << ". " << Verbs [i] << endl;
}
system("pause");
break;
case '4':
system("cls");
cout << "\n\n";
cout << " Prepositions\n";
for (i = 0; i < 5; i++)
{
cout << " " << i << ". " << Prepositions [i] << endl;
}
system("pause");
break;
case '5':
system("cls");
break;
case '\n':
break;
default: cout << '\a';
}
}
while( selection != '5');
}
void Change_Words()//Option 2
{
system("cls");
char selection;
do
{
system("cls"); // Clear the screen
cout<<"\n\n Change words\n\n"
<<" 1 <- Article\n"
<<" 2 <- Nouns\n"
<<" 3 <- Verbs\n"
<<" 4 <- Prepositions\n"
<<" 5 <- Return to Main Menu\n\n"
<<" Choice : ";
cin.get(selection);
switch (selection)
{
case '1':// Articles
system("cls");
cout << "\n\n";
cout << " Articles\n";
for (i = 0; i < 5; i++)
{
cout << " " << i << ". " << Articles[i] << endl;
}
cout << " Number :";
cin >> Number;
i = Number;
Articles[i];
cout <<" Replace with: ";
cin >> Replace;
Articles[Number] = Replace;
for (i = 0; i < 5; i++)
{
cout << " " << i << ". "<< Articles[i] << endl;
}
system("pause");
break;
case '2': // Nouns
system("cls");
cout << "\n\n";
cout << " Nouns\n";
for (i = 0; i < 5; i++)
{
cout << " " << i << ". " << Nouns[i] << endl;
}
cout << " Number :";
cin >> Number;
i = Number;
Nouns[i];
cout <<" Replace with: ";
cin >> Replace;
Nouns[Number] = Replace;
for (i = 0; i < 5; i++)
{
cout << " " << i << ". "<< Nouns[i] << endl;
}
system("pause");
break;
case '3': // Verbs
system("cls");
cout << "\n\n";
cout << " Verbs\n";
for (i = 0; i < 5; i++)
{
cout << " " << i << ". " << Verbs[i] << endl;
}
cout << " Number :";
cin >> Number;
i = Number;
Verbs[i];
cout <<" Replace with: ";
cin >> Replace;
Verbs[Number] = Replace;
for (i = 0; i < 5; i++)
{
cout << " " << i << ". "<< Verbs[i] << endl;
}
system("pause");
break;
case '4':
system("cls");
cout << "\n\n";
cout << " Prepositions\n";
for (i = 0; i < 5; i++)
{
cout << " " << i << ". " << Prepositions[i] << endl;
}
cout << " Number :";
cin >> Number;
i = Number;
Prepositions[i];
cout <<" Replace with: ";
cin >> Replace;
cout <<" updated list: " << endl;
Prepositions[Number] = Replace;
for (i = 0; i < 5; i++)
{
cout << " " << i << ". "<< Prepositions[i] << endl;
}
system("pause");
break;
case '\n':
break;
case '5':
system("cls");
break;
default:
cout << '\a';
}
}
while( selection != '5');
}
void Write_Sentence()//Option 3
{
system("cls");
int num;
cout << "\n\n Here's the sentence:\n\n ";
cout << "Sentence -> " << Articles[Sentence(num)] << " " << Nouns[Sentence(num)]//Function call
<< " " << Verbs [Sentence(num)] << " " << Prepositions[Sentence(num)]
<< " " << Articles[Sentence(num)] << " " << Nouns[Sentence(num)] << endl;
//The line above display a sentence in the order of article,
//noun, verb, preposition, article, noun
cout << endl;
system("pause");
}
void Create_Story() // Option 4
{
system("cls");
int number_lines;
int num;
cout << "\n\n How many lines are there in the story?\n"
<< " Lines : ";
cin >> number_lines;
cout << "\n Here's the story :\n"
<<" -------------------\n";
//string Articles [5] = {"a", "the" ,"one" , "some" ,"any" };
for ( int j = 0; j <= number_lines; j ++)
{
char ch = toupper(Articles[0][0]);
cout << ch;
cout << " " << Articles[Sentence(num)] << " " << Nouns[Sentence(num)]
<< " " << Verbs [Sentence(num)] << " " << Prepositions[Sentence(num)]
<< " " << Articles[Sentence(num)] << " " << Nouns[Sentence(num)] << ".\n";
}
system("pause");
}