Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Problem A: Commenter Write a C++ program that lets you enter as many sentences as you want (assume less than 100). Keep allowing the user

Problem A: Commenter Write a C++ program that lets you enter as many sentences as you want (assume less than 100). Keep allowing the user to enter sentences until they type a single line with the word exit (no quotes). At this point, you should display everything that they had written, except removing an parts that are comments. Use the normal C++ rules for commenting, where // comments out only the rest of the current line and /* will continue commenting until a */ is reached.

If a comment comments out the full line (no spaces or anything outside of the comment), do not display anything for this line. In other words, fully removed lines should not become blank after removing comments, just show the next line that is non-blank. You should also treat blank lines in the input the same way, just simply ignore them and do not show them in the output.

For this part, you may assume there is at most one comment indication per line. In other words, you will not have a sentence like:

I /* like */ apples ... you may also assume that every /* will have a closing */ and that exit will not be typed in the

middle of a comment. For example, we will not test for something like this (no tabs/spaces in input):

/* start comment exit did I catch you? */

Example 1 (user input is underlined):

hi there you are my friend lets have fun // just kidding, you are a total jerkface lets /* play a game called */ guess exit hi there you are my friend lets have fun lets 

guess

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Object Oriented Databases Prentice Hall International Series In Computer Science

Authors: John G. Hughes

1st Edition

0136298745, 978-0136298748

More Books

Students also viewed these Databases questions