944,120 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 812
  • C++ RSS
Nov 16th, 2007
0

Urgent help in this code plz

Expand Post »
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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Love Story is offline Offline
2 posts
since Nov 2007
Nov 16th, 2007
0

Re: Urgent help in this code plz

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!
Reputation Points: 13
Solved Threads: 0
Light Poster
joshua.tilson is offline Offline
47 posts
since Nov 2007
Nov 16th, 2007
0

Re: Urgent help in this code plz

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);
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Love Story is offline Offline
2 posts
since Nov 2007
Nov 16th, 2007
0

Re: Urgent help in this code plz

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

Start here
C++ Syntax (Toggle Plain Text)
  1. #include <string>
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. // put your code here
  8.  
  9. return 0;
  10. }
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2283
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,961 posts
since Aug 2005
Nov 16th, 2007
0

Re: Urgent help in this code plz

Since you've got the algorithim...it shouldn't be that hard....please post what you've got so far!
Featured Poster
Reputation Points: 129
Solved Threads: 26
Nearly a Posting Maven
zandiago is offline Offline
2,463 posts
since Jun 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: error C2447: '{' : missing function header (old-style formal list?)
Next Thread in C++ Forum Timeline: urgent....need to make fragments of string





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC