{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

cp2_4_ps07_s04

# cp2_4_ps07_s04 - code 3 a Compare and contrast stacks and...

This preview shows pages 1–2. Sign up to view the full content.

CP2-4 The problems in this problem set cover lectures C2, C3, and C4. 1. Part a. Write an algorithm to check if a user entered string is a palindrome. Assume: i. Maximum string length is 80 characters ii. The actual string length is input dependent Part b. Implement your algorithm as an Ada95 program. Turn in a hard copy of your algorithm and code listing; and an electronic copy of your code. 2. Modify the program above to read inputs from a text file and store the reversed string in an output text file. The program should: a. If the line of text is a palindrome, store it in the output file. b. If it is not a palindrome, reverse the line of text and store the reversed line of text in the output file. c. Repeat the above steps until there are no more inputs to be processed from the input file. Assume: i. Input file name is my_program_input.txt ii. Output file name is my_program_output.txt Turn in a hard copy of your algorithm and code listing and an electronic copy of your

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: code. 3. a. Compare and contrast stacks and queues. Hint: Summarize the operations on stacks and queues using a table and use a diagram to show the difference between basic operations. b. Modify the expression conversion algorithm shown in class to include unary operators. Hint: i. Unary operators operate on only one argument. -5, +9 etc ii. How do you distinguish between a unary and binary operator? (Think about the number of arguments) Unifed Engineering Spring 2004 iii. Use the following test expression -5 + 9 + -6 + 2 to see if the conversion works. Assume: i. The unary operators are only ‘+’ and ‘-’. ii. Inputs are user input strings of maximum length 80. c. Implement your algorithm as an Ada95 program. Turn in a hard copy of your algorithm and code listing, and an electronic copy of your code....
View Full Document

{[ snackBarMessage ]}

### Page1 / 2

cp2_4_ps07_s04 - code 3 a Compare and contrast stacks and...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online