You will then insert the code that outputs the text. You will be inserting indiv
ID: 3678686 • Letter: Y
Question
You will then insert the code that outputs the text.
You will be inserting individual words into the arrays; nouns, verbs, adjectives, etc. You'll need to fill each array with 10 words of each type as specified. If you have trouble coming up with words Google "list of nouns" and get hundreds of thousands of samples.
Important: Initialize the arrays at declaration time. Do not fill the arrays with code inside the main function, but where they are declared - just as I did above with the Prompt[7] string array.
Insert the array names in the "letter to home" in the main function by taking the text out of the comments (/* and */) and placing them in cout commands. Substitute the names in the < and > characters with the array names and indexes. Use random numbers for the array indexes (random number generating code is supplied).
Each time the program runs, different words will be selected from the string table and inserted in the letter courtesy of the random indexes.
If you get creative with the values in your string table it should be fun - or at least entertaining - when you test your code.
Insert your program documentation and code comments.
Provide program documentation and comment the entire program, including the code that was given to you.
Code.......
#include "stdafx.h"
#include <iostream>
#include <iomanip>
#include <string>
#include <random>
using namespace std;
const int MAX_WORDS = 10;
string Noun_1[MAX_WORDS]; // person, place or thing
string Noun_2[MAX_WORDS]; // person, place or thing string
Noun_3[MAX_WORDS]; // person, place or thing
string Noun_S[MAX_WORDS]; // person, place or thing, ending in the letter 's'
string Verb_1[MAX_WORDS]; // action
string Verb_2[MAX_WORDS]; // action
string Verb_ED[MAX_WORDS]; // action, ending in the letters 'ed'
string Adverb[MAX_WORDS]; // descriptive of a verb
string Adjective_1[MAX_WORDS]; // modifyer
string Adjective_2[MAX_WORDS]; // modifyer
string Adjective_3[MAX_WORDS]; // modifyer
string Color[MAX_WORDS]; // red, green, etc.
string Relative[MAX_WORDS]; // person
string School[MAX_WORDS]; // place
string Time[MAX_WORDS]; // time of day, any format
int _tmain(int argc, _TCHAR* argv[])
{ // randome number generator, run these three lines once at the beginning of the program random_device rd; // non-deterministic generator mt19937 gen(rd()); // to seed mersenne twister. uniform_int_distribution<> dist(0,9); // distribute results between 0 and 9 inclusive. dist(gen); // insert dist(gen) everywhere you need a random number between 0 and 9 /* Dear <Relative>, I am having a(n) <Adjective_1> time here at <School>. My teachers are all <Adjective_2> and I am doing quit <Adjective_3>. Yesterday, I <Verb_ED> all day. It was <Adverb> <Verb_1> all afternoon but changed to <Color> by <Time>. I met a new <Noun_1>. I call him <Name_2> and we <Verb_2> every day. Please send <Noun_2> to help pay for <Noun_S>. Love <Name_3>. */ system("Pause"); return 0; }
Explanation / Answer
#include <iostream>
#include <iomanip>
#include <string>
#include <random>
using namespace std;
const int MAX_WORDS = 10;
string Noun_1[MAX_WORDS] = {"John","people","health","method","nature","community","movie","technology","Rohan","Mohan"}; // person, place or thing
string Noun_2[MAX_WORDS] = {"boy","bun","can","cake","cap","car","cat","cow","cub","dad"}; // person, place or thing string
string Noun_3[MAX_WORDS] = {"kite","man","map","men","mom","pan","pet","pig","toe","tub"}; // person, place or thing
string Noun_S[MAX_WORDS] = {"Amadeus","Atticus","Aurelius","Augustus","Angus","Amias","Justus","Linus","Lucas","Julius"}; // person, place or thing, ending in the letter 's'
string Verb_1[MAX_WORDS] = {"need","know","find","take","want","come","become","choose","develop","improve"}; // action
string Verb_2[MAX_WORDS] = {"occur","write","seem","receive","solve","reduce","speak","hear","remain","forget"}; // action
string Verb_ED[MAX_WORDS] = {"abashed","acquired","admitted","advised","agreed","answered","arrested","asked","attracted","bashed"}; // action, ending in the letters 'ed'
string Adverb[MAX_WORDS] = {"well","quickly","softly","loudly","beautifully","greedily","happily","fastly","slowly","gently"}; // descriptive of a verb
string Adjective_1[MAX_WORDS] = {"Good","New","First","Last","Long","Great","Little","own","other","old"}; // modifyer
string Adjective_2[MAX_WORDS] = {"big","high","different","small","large","next","early","young","important","few"}; // modifyer
string Adjective_3[MAX_WORDS] = {"beautiful","sleeveless","meaningless","edible","nicer","ugly","breakable","many","much","little"}; // modifyer
string Color[MAX_WORDS] = {"Red","Green","Blue","White","Black","Orange","Black","Brown","Pink","Grey"}; // red, green, etc.
string Relative[MAX_WORDS] = {"Aunt","Uncle","Brother","Sister","Mom","Dad","Grandfather","Grandmother","Niece","Nehpew"}; // person
string School[MAX_WORDS] = {"Satluj Public School","DAV Public School","The Shri Ram School","Delhi Public School","IIT Delhi","IIT Bombay","IIT kanpur","IIT Roorkee","NIT KKR","DTU Delhi"}; // place
string Time[MAX_WORDS] = {"12:30","12:35","17:54","5:43","2:30","1:30","6:12","8:17","10:20","8:20"}; // time of day, any format
int main(){
random_device rd;
mt19937 gen(rd());
uniform_int_distribution<> dist(0,9);
cout << "Dear " << Relative[dist(rd)] << " , I am having a(n) " << Adjective_1[dist(rd)] << " time here at " << School[dist(rd)] << ". My teachers are all " << Adjective_2[dist(rd)] << " and I am doing quit " << Adjective_3[dist(rd)] << ". Yesterday, I " << Verb_ED[dist(rd)] << " all day. It was " << Adverb[dist(rd)] << " " << Verb_1[dist(rd)] << " all afternoon but changed to " << Color[dist(rd)] << " by " << Time[dist(rd)] << " .I met a new " << Noun_1[dist(rd)] << ". I call him " << Noun_2[dist(rd)] << " and we " << Verb_2[dist(rd)] << " every day. Please send " << Noun_2[dist(rd)] << " to help pay for " << Noun_S[dist(rd)] << ". Love " << Noun_3[dist(rd)] << endl;
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.