Urgent help in this code plz

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Nov 2007
Posts: 2
Reputation: Love Story is an unknown quantity at this point 
Solved Threads: 0
Love Story Love Story is offline Offline
Newbie Poster

Urgent help in this code plz

 
0
  #1
Nov 16th, 2007
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.
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 47
Reputation: joshua.tilson is an unknown quantity at this point 
Solved Threads: 0
joshua.tilson's Avatar
joshua.tilson joshua.tilson is offline Offline
Light Poster

Re: Urgent help in this code plz

 
0
  #2
Nov 16th, 2007
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!
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 2
Reputation: Love Story is an unknown quantity at this point 
Solved Threads: 0
Love Story Love Story is offline Offline
Newbie Poster

Re: Urgent help in this code plz

 
0
  #3
Nov 16th, 2007
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);
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,359
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1464
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is online now Online
Still Learning

Re: Urgent help in this code plz

 
0
  #4
Nov 16th, 2007
>>i have no idea how to make it a code:

Start here
  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. }
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Jun 2007
Posts: 2,462
Reputation: zandiago is on a distinguished road 
Solved Threads: 25
Featured Poster
zandiago's Avatar
zandiago zandiago is offline Offline
Nearly a Posting Maven

Re: Urgent help in this code plz

 
0
  #5
Nov 16th, 2007
Since you've got the algorithim...it shouldn't be that hard....please post what you've got so far!
I shot the sheriff....but I didn't shoot the deputy
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC