Write a program that uses random-number generation

Assignment Help C/C++ Programming
Reference no: EM132058073

Question: 1. Write a program that uses random-number generation to create sentences. Create four arrays of strings (string objects highly suggested over c-strings) called article, noun, verb, and preposition.

2. The arrays of Strings:

• The article array should be const and contain the articles: "the", "a", "one", "some", "any"

• The preposition array should be const and contain the prepositions: "to", "from", "over", "under", "on"

• The noun array and the verb array should contain words entered by the user. So start the program by asking the user to enter 5 nouns (each seperated by a space -- this should give you a hint as to how to read them in), and then ask them to enter 5 verbs (again, each seperated by a space). Store these in the appropriate arrays.

• Ensure that all the words stored in the noun array and the verb array are stored as all lowercase words. The user could enter a word with any case they choose, but it's up to you to store them as lowercase strings in your array. You may assume the user will enter valid verbs whem prompted and valid nouns when prompted.

3. Create a sentence by selecting a word at random from each array in the following order: article, noun, verb, preposition, article, noun
This means, you need to generate a random value for each array to grab a word. Example: You cannot generate one random value (say, 1) and then take index 1 of each array. You must generate a random value to use as the index in each array you'll get a word from.

4. As each word is picked, concatenate it to the previous words in the sentence. The words should be separated by spaces. When the final sentence is output, it should start with a capital letter and end with a period. Your program should generate random 20 sentences and output them to the console.

5. Note: It's not enough to output just one word at a time. You need to create each sentence as a single string before printing it to output. (Make use of the concatenation operation! String objects make this easy!)

6. Hint: The hardest part is making sure the sentence is capitalized, because you only have one article array (and it stores the lowercase version, since you use articles again). Remember that we've seen a number of methods from the string class, that help with this. You may want to remind yourself of these:

• In the cctype library, we saw functions that can check for upper or lowercase characters and even some that can change values from uppercase to lowercase and vice versa.

• From string class, at, [] notation, and the + operation will also be helpful.

7. Functions in addition to main() are not required but it may be a good idea for you to create some if you find yourself needing to do a similar task over and over.

Reference no: EM132058073

Questions Cloud

What is the concentration of caffeine in tea : A cup of 125 mL of reasonably strong Twinings English BreakfastTM tea has approximately 110 mg of caffeine.
Calculate the mass of pure glucose : Calculate the mass of pure glucose contained in a 60.0 kg tank that is a 5.0% by mass glucose solution.
What was the amount of direct materials charged : Worrell Corporation has a job-order costing system. What was the amount of direct materials charged to Job No. 232
Concentration of the solute needed to produce : Write dissociation equation and calculate the concentration of the solute needed to produce a Fe2 SO4 solution with 0.600 mol/L iron(III) ions.
Write a program that uses random-number generation : Write a program that uses random-number generation to create sentences. Create four arrays of strings (string objects highly suggested over c-strings).
Percentage of weight per volume : What is the concentration of caffeine in the cup of coffee, expressed as a percentage of weight per volume?
Calculate the break-even point in units for larson co : Larson Co. produces telephone answering machines. Calculate the break-even point in units for Larson Co
Helium gas toeffuse through a pinhole into a vacuum : If it takes 6.5 seconds for 25 cm3 of helium gas toeffuse through a pinhole into a vacuum, how long would it take for25 cm3 of CH4
What is the rate constant : A 6.70 g sample of is allowed to decay. If 2.20 g of this isotope remains after 10.0 days, what is the rate constant?

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd