| | |
Urgent help in this code plz
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Nov 2007
Posts: 2
Reputation:
Solved Threads: 0
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.
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.
•
•
Join Date: Nov 2007
Posts: 2
Reputation:
Solved Threads: 0
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);
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
Start here
C++ Syntax (Toggle Plain Text)
#include <string> #include <iostream> using namespace std; int main() { // put your code here return 0; }
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.
![]() |
Similar Threads
- how to write code for update,delete,cancel buttons in datagrid using vb.net only..plz (IT Professionals' Lounge)
- searching and paging..plz help.. (ASP)
- Can some one help me with this code plz (Visual Basic 4 / 5 / 6)
- urgent help required plz help (C)
- MERGED: Deleting duplicates in an array (plz help me out!!!!!!!) (C)
- URGENT: Need help on I/O code! (Java)
Other Threads in the C++ Forum
- Previous Thread: error C2447: '{' : missing function header (old-style formal list?)
- Next Thread: urgent....need to make fragments of string
| Thread Tools | Search this Thread |
api array based binary bitmap c++ c/c++ calculator char char* class code coding compile compiler console conversion count database delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game getline givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int java lib linkedlist linker list loop looping loops map math matrix memory multiple news node number numbertoword output pointer problem program programming project proxy python random read recursion recursive reference rpg sorting string strings temperature template test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






