hi everyone,

it's my first thread here and i need help plz with this question below:


The purpose of the program is as follows. A line of programming code is to be entered from the keyboard. Part of the code will be contained between a “Begin” string and an “End” string. The program is to write out the block of statements between these two strings. For example, if the input line is :
Some blocks of programming start with Begin statement1 statement2 and finish with End statement3 statement4.
The output will be: statement1 statement2 and finish with
i. Write the data table and the final design for this program.
ii. Write a C++ program as a console application to implement the design. You can b. You are now asked to design, and to implement, a program to check that “Begin” and “End” in a sentence match. For example, the “Begin” and “End” fail to match in each of these sentences:

This code Begin is used Begin for testing End purpose.
This code with Begin some words End is for End testing Begin code.
The first has a missing “End” and the second, although having two of each, has “Begin” and “End” which do not pair up correctly.
Submit the program to your tutor along with five runs of your program using input lines of your choice. Annotate each output with a brief comment indicating what aspect of the program is being tested by this choice of input line.

Recommended Answers

All 4 Replies

Ok, I will be the first.
Please show us what you have worked out so far (Per the board rules) and some one will most likely be willing to help you figure out how to proceed.

Thanks!

hi,

this is the design but i have no idea how to make it a code:

Top-Level Design

1 Initialize Variables

2 Read in Input_String

3 Loop while not all Input_String charactes have been processed

4 Process character

5 Loopend

As for (ii), it is as follows:

Fill in the missing information to make the design in the final stage ready for coding.

Final Design:

1.1 Writing ← ­­ ­­_________

1.2 _____________ //Initialization required

2.1 _____________________________________ //Refinement of step 2

2.2 _____________________________________ //Refinement of step 2

3.1 loop while ____________________________

/*Step 4.1 is used to skip all leading space characters if any

to reach the start of a word or end of string*/

4.1.1 loop while Input_String [ String_Index ] = ' ' and String_Index < Length ( Input_String )

4.1.2 if Writing then

4.1.3 write out Input_String [ String_Index ]

4.1.4 else

4.1.5 do nothing

4.1.6 ifend

4.1.7 String_Index ← __________________

4.1.8 loopend

4.2.1 if ___________________________________ then //Found the beginning of a word

4.2.2 Index_Word_Start ← _______________ //Mark the beginning of a word

//Step 4.2.3 is used to Mark the end of a word

4.2.3.1 loop __________________________________________________________

4.2.3.2 _____________________________________

4.2.3.3 loopend

4.2.4.1 if String_Index < Length ( Input_String ) then

4.2.4.2 Index_Word_End ← ____________________

4.2.4.3 if String_Index = Length ( Input_String ) then

4.2.4.4 Index_Word_End ← _________________

4.2.4.5 else

4.2.4.6 do nothing

4.2.4.7 ifend

4.2.5 Temp_Word ← SubString of Input_String from

Index_Word_Start to Index_Word_End

//Check if word is "Begin"

4.2.6.1 if Temp_Word = "Begin" then

4.2.6.2 Writing ← _____________

4.2.6.3 else

4.2.6.4 if Temp_Word = "End" then

4.2.6.5 Writing ← _____________

4.2.6.6 else

4.2.6.7 if Writing then

4.2.6.8 write out ______________

4.2.6.9 else

4.2.6.10 do nothing

4.2.6.11 ifend

4.2.6.12 ifend

4.2.6.13 ifend

4.2.7 else

4.2.8 do nothing

4.2.9 ifend

4.2.10 else

4.2.11 do nothing

4.2.12 ifend

5.1 loopend

Note: the C++ implementation code for step 4.2.5 above may be easily done using a ready function, as follows:

Temp_Word = Input_String.SubString(Index_Word_Start, Index_Word_End - Index_Word_Start);

>>i have no idea how to make it a code:

Start here

#include <string>
#include <iostream>
using namespace std;

int main()
{
   // put your code here

   return 0;
}

Since you've got the algorithim...it shouldn't be that hard....please post what you've got so far!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.