![]() |
|
#1
|
|||
|
|||
Help with interactive program, pleaseI started to write this program but can't even get through the 1st part of it. Please, help.
Objective: White an interactive program which makes a preliminary diagnosis of influenza, cold, allerty, or unknown. The output must look like the following: Clark Hospital Diagnostic Center (Note 1) Enter the patient number (0 to exit): 452382 Invalid patient number (Note 2) Enter the patient number (0 to exit): 453282 Which of the following symptoms does the patient have (Y for yes, N for no); Fever -------- y (Note 3) Headache ----- N Sore Throat -- m Invalid entry. Sore Throat -- Yes Cough -------- y Sniffles ----- n Sneezes ------ n The preliminary diagnosis is: Influenza (Note 4) Enter the patient number (0 to exit): 0 (Note 5) Diagnostic Program Terminated Notes 1. Display this heading line only once i.e. when the program is first started up. 2. If the patient number fails to pass the mod 10 check digit technique, display "Invalid patient number." and prompt the user to enter a correct patient number. The mod 10 check digit technique is discussed below. 3. Allow for either an upper or lower case response. If the response is neither Y, y, N nor n, display "Invalid entry." and reprompt the user. Use either getc(stdin) or its variant getchar(c) for reading the user response. Finally, your program should have no difficulty dealing with responses such as Yes, NO, YUP, NOPE etc. as-long-as the first character can be construed as a yes or no response. 4. It is entirely possible the patient might have more the one diagnosis, be sure to display all possibilities. 5. If a patient number of 0 (zero) is entered, terminate the program else continue to prompt for symptoms. Technique: mod 10 Check Digit To generate a check digit using the mod 10 technique, work from right to left. First multiply the digits in the odd positions by 2. if an individual result is greater than 10, add 1 to the units position to obtain a single digit adjusted result. Sum the results along with the even-positioned digits. The number that must be added to make this result evenly divisible by 10 is the check digit. (page 423) Example: Consider a patient number 835174. The least significant digit (4) is the check digit. To determine if the (actual) patient number (83517) is a valid patient number do the following: 1. Extract the odd numbered digits from right to left from the actual patient number. These would be 7, 5 and 8. 2. Multiply each by 2: 7 · 2 = 14 5 · 2 = 10 8 · 2 = 16 3. If any of the products from step 2 are greater than 10, add 1 to the units position and discard the remainder of the product e.g. since 7 · 2 = 14 add 1 to 4 (the units position) and discard everything else. 4. Sum the adjusted products plus the digits from the even numbered positions: 5 + (1) + 10 + (3) + 7 = 26 (the digits in parenthesis are the even numbered digits). 5. Find the largest number greater than or equal to the above sum evenly divisible by 10 - 30 for this example. 6. Find the difference between the next largest number (30) and the sum (26) i.e. 30 - 26 = 4. Four is the check digit. Any digit other than 4, would invalidate the patient number 83517[.] This is what I have so far (for the mod 10 check digit): CPP / C++ / C Code:
My problem at this point is that after I enter the patient number and press return key, nothing happens. The pointer gets me to the new line and just sits there. I cannot figure out where did I go wrong in my source code. Please, somebody help. thank you. ![]() Last edited by LuciWiz : 08-May-2005 at 23:13.
Reason: Please insert your C code between [c] & [/c] tags
|
|
#2
|
||||
|
||||
|
First, read the Guidelines.....
Second, why are you using fputs(..., stdout) then printf()? Use one or the other... Try putting printf() statements in key spots (after your input, after calculations, etc.) to see what your program is doing. You will then find that CPP / C++ / C Code:
__________________
Age is unimportant -- except in cheese |
Recent GIDBlog
Meeting the populace by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Airport Log program using 3D linked List : problem reading from file | batrsau | C Programming Language | 11 | 29-Feb-2008 07:44 |
| [TUTORIAL] Calling an external program in C (Linux) | dsmith | C Programming Language | 4 | 22-Apr-2005 13:30 |
| fltk-2.0 cvs | Plumb | FLTK Forum | 20 | 13-Nov-2004 07:10 |
| Need help with a C program (Long) | McFury | C Programming Language | 3 | 29-Apr-2004 20:06 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The