CSC141, Computer Science, Fall 03

Project 3 assignment

Due Date: For session 1, due by Nov. 10th, 2003, for session 06, due by Nov. 11th, 2003. Late programs are usually penalized at least 50%.

Part 1.

Input your grade (a number from 0 to 100). If the value of a grade is not a number between 0 and 100, print the error message “Please try again” to the screen and quit; Otherwise print the letter representation (A,B,C,D,F) of the number grade. Following are the appropriate number to letter grades assignments:

A -> 100-90

B -> 89-80

C -> 79-65

D -> 64-60

F -> 0-59.

Part 2.

Write a program to simulate a calculator. You will supply as input to your program two numbers (any real number) and an operator (+,-,*,%,or /). Your program will print the result to the screen. For operator %, need to figure out it is illegal if any number is float number (decimal part is not zero).

Part 3.

Write a program that converts feet and inches to meters or visa versa. 1 inch = 2.54 cm.

For example:

1)Example 1:

Meter to foot-inch (Y)/ foot-inch to Meter (N): n

Input foot: 6

Input inch: 5

Output meters: 1.96

2)Example 2:

Meter to foot-inch (Y)/ foot-inch to Meter (N): n

Input foot: 0

Input inch: 77

Output meters: 1.96

3)Example 3:

Meter to foot-inch (Y)/ foot-inch to Meter (N): y

Input meters: 1.96

Output: 6 feet and 5 inches

4)Example 4:

Meter to foot-inch (Y)/ foot-inch to Meter (N): y

Input meters: 0.125

Output: 0 foot and 5 inches

Part 4.

Implement a program to simulate a Hollywood square:

Input three different numbers, to check if they are in the same column, row or diagonal.

For example:

1) Input three positions: 1 2 3

Answer: No

2) Input three positions: 8 1 6

Answer: Yes

3) Input three positions: 2 5 8

Answer: Yes

Part 5.

Develop a program show all the operations for string. Show the information first:

Input your choices for string operations:

0: string a + string b (attach)

1: string a = string b (copy)

2: find string a in string b

3. get the length of string a

4. get the sub-part of string a from position x to position y.

5. get the left part of string a with x characters

6. get the right part of string a with x characters

7. replace the subpart, string b, inside the big string a, by string c

For cases 0,1,and 2, you need input two strings and show the result (or founded/Not founded)

For case 3, you need input just one string and then, print a number which represents the number of characters in the string.

For case 4, input a string and a position number x which represents the starting position of the sub-string and a position number y which represents the ending position. Print the sub-string.

For case 7, input three strings, i.e., “Hellohowareyou”, “are”, and “am”, and then, show the result: “Helloamyou”.

For any input string, assume it contains no space. Suppose in case 7, string b should be inside string a and there is no duplicate.

Evaluation:

  1. Explain how you solved the problem in English (describe your algorithm). Also tell me what you think the main learning objective was for this assignment.
  2. Write down anything (statement, concept, or programming technique) new for you in this project and write down the most difficult thing here for you in this project and how you figured out.