| Thread Closed |
Help! need to write fortran program |
Share Thread | Thread Tools |
| Mar17-08, 11:19 AM | #1 |
|
|
Help! need to write fortran program
I have this program that needs to be written, but I dont know where to start. Can someone please help me with it.Thanks
*1 Problem Statement Mrs. Deli is running the delicatessen store “Deli Deli”. Last year Mrs. Deli has decided to expand her business andbuild up an on-line store. She has hired a programmer who has implemented the on-line store. Recently some of her new on-line customers complained about the electronic bills. The programmer had forgotten touse the plural form when reporting that an item is purchased multiple times. Unfortunately the programmer of Mrs.Deli is on holiday and now it is your task to implement this feature for Mrs. Deli. Here is a description how to make the plural form: 1. If the word is in the list of irregular words replace it with the given plural. 2. Else if the word ends in a consonant followed by "y", replace "y" with "ies". 3. Else if the word ends in "o", "s", "ch", "sh" or "x", append "es" to the word. 4. Else append "s" to the word. 2 Inputs Your program should accept a single file name as a command line parameter. This parameter will be the name of a filecontaining the all of the input data items, as described below. The file name may be as long as 256 characters. Your program should not prompt the user for any input information. The first line of the input file consists of two integers L and N (0 is less than or equal to L is less than or equal to 100, 1 is less than or equal to N is less than or equal to 1000) The next L lines contain the description of the irregular words and their plural form. Each line consists of two wordsseparated by a space character, where the first word is the singular, the second word the plural form of some irregularword. After the list of irregular words, the remaining N lines contain one word each, which you have to make plural. Youmay assume that each word consists of at most 20 lowercase letters from the English alphabet (’a’ to ’z’). 3 Outputs All output should be written to the the default, standard, output device. Print N lines of output, where the ith line of output is the plural form of the with input word 5.1.1 Sample Input The contents of a file named sample_input.txt: 3 7 rice rice spaghetti spaghetti octopus octopi rice lobster spaghetti strawberry octopus peach turkey 5.1.2 Sample Execution Running the program (complied as the executable named deli) with the above sample data file will yield these results: rice lobsters spaghetti strawberries octopi peaches turkeys |
| PhysOrg.com |
science news on PhysOrg.com >> Hong Kong launches first electric taxis >> Morocco to harness the wind in energy hunt >> Galaxy's Ring of Fire |
| Mar19-08, 01:55 AM | #2 |
|
|
wow who in the hell uses fortran to program this kind of software? what class is this you're taking? are you supposed to use f90? f95? f77?
|
| Mar19-08, 12:43 PM | #3 |
|
Recognitions:
|
Also, who did the grammar? As I recall "octopus" has proper English "octopuses" and Latin plural "octopodes".
|
| Mar20-08, 01:14 PM | #4 |
|
|
Help! need to write fortran program |
| Mar20-08, 02:14 PM | #5 |
|
|
This is for intro to fortran. We have to us f95/2003
|
| Mar20-08, 02:34 PM | #6 |
|
Mentor
|
|
| Apr1-08, 04:12 AM | #7 |
|
|
Just be thankful it's not FORTRAN IV...
|
| Apr1-08, 01:28 PM | #8 |
|
|
That will be a pain in the ***. Good luck.
I'd start with the irregular word first, since you can go through the list and just compare whether or not yourWord == word1, word2, etc. until you find it and replace it. Playing around with the individual characters will NOT be fun. I haven't done any string processing in F, only C++, but I remember a string being an array of characters, right? so you'd have to check the last 1 or two characters and just add more to the array or change some characters. I don't know whether or not String is a dynamic array or just has a set limit of characters, but you should probably copy your word array into a new one with x + 2 (for ies or es) slots and work your magic there. |
| Apr12-08, 05:36 AM | #9 |
|
|
Well Fortran is mostly developed for scientific calculations, but I think string processing is not very hard if you know how to it. Fortran doesn't have the String datatype but instead an array of characters. So if you want to have a word with l characters you define the type as
character(len=l)::word. So in the problem you need to define word as a character array with l=maximum length a word can have. The characters i to j in the array word can be changed by word(i:j)="..." So now I think it's quite easy for you too go further. |
| Thread Closed |
| Thread Tools | |
Similar Threads for: Help! need to write fortran program
|
||||
| Thread | Forum | Replies | ||
| help with fortran program | Programming & Comp Sci | 6 | ||
| Help me to write fortran code | Programming & Comp Sci | 1 | ||
| running a Fortran 77 program in a C++ enviorment/program | Programming & Comp Sci | 2 | ||
| problem in fortran program | Programming & Comp Sci | 0 | ||
| help with simple Fortran program | Programming & Comp Sci | 1 | ||