Homework 8:
Short Description:
This assignment is worth 10 points.
Goals
When you finish this homework, you should
- Be able to use pipes to communicate with a process
Formal Description
Write two programs.
- Write a program that reads in an integer, converts that integer to a value between 0 and 19 using mod functions, and returns the string associated with the given integer. This program should be called EightBall. The answer it returns should correspond with those listed on this page.
For Example
% EightBall
0
It is certain.
% EightBall
19
Very doubtful.
% EightBall
20
It is certain.
- Write a second program called EightBallInterface. This program should
- Read in a string
- If the string is "QUIT" exit, otherwise
- Compute the "value" of the string by summing all of the letters in the string (a=0, b=1,...)
- Call the EightBall program with the sum of the letters.
- Print out the value EightBall Returned
- Repeat
Notes
You must use pipe(), fork(), exec*() in this program.
Submission
Submit all programs in a tar file to your instructor as an attachment to an email message by the due date.