Algorithm

I want to develop an algorithm that solves the Y2k problem by changing all the y's to k's in a documents.(can be assumed that a document is merely and array of characters) What are good especifications for it?
q_lowAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

snifongCommented:

#include <fstream.h>
#include <iostream.h>

void main()
{
char c;
ifstream Infile("input.txt", ios::in);
ofstream Outfile("output.txt", ios::out);
   while((c=Infile.get()) != EOF) {
      if((c=='y')||(c=='Y'));
            Outfile.put('k');
   }
}
0
snifongCommented:
Sorry.  This is a little different.  It writes to another file.
#include <fstream.h>
#include <iostream.h>

void main()
{
char c;
ifstream Infile("input.txt", ios::in);
ofstream Outfile("output.txt", ios::out);
   while((c=Infile.get()) != EOF) {
      if((c=='y')||(c=='Y'));
         Outfile.put('k');
      else
         Ouputfile.put(c);
   }
}
0
q_lowAuthor Commented:
What about specifications?
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

nietodCommented:
We cannot provide answers to school assignments.  That is grounds for removal from this site.  (for both you and the experts involved.)  We can provide only limitied help in accademic assignments.    We can answer specific (direct) questions, like you might ask your teacher.  We can review your work and post suggestions, again, like your teacher might do.

Do you have specific questions?
Do you have any work on this (incomplete even) that we can review?
0
snifongCommented:
Post a few of the ones that you think should be there and then let us look at them and help you out where you are stuck.
0
q_lowAuthor Commented:
nietod...this is no school assigment if you are learning this by yourself. So i make it clear it ain't an assigment. As far as code is concern, I'm working on it again to post it so you can give me a better help, had a pc crashed and had to get a new disk so i don't have my program.Thanx
0
q_lowAuthor Commented:
What I meant by specifications in the question was meant to be like this:
if array has to have at least one element, etc....
0
q_lowAuthor Commented:
Not what i asked for. I asked by specifications not a program
0
nietodCommented:
What do you mean by specifications?  And why do you need them?
0
q_lowAuthor Commented:
Well to have some idea what i got to do in the problem.I feel it is too ambiguous. So I am asking you what do I have to take in consideration to make the program.
0
snifongCommented:
What do you have so far?
0
SISUCommented:
Hi,
  Use the followinf code

void main()
{
char c;
fstream Outfile("output.txt",ios::in|ios::out);
   while((c=Outfile.get()) != EOF)
   {
      if((c=='y')||(c=='Y'))
      {  outfile.seekp(-sizeof(c),ios::cur);
         Outfile.put('k');
      }
    }
}
Hope this will help U

Sisu
0
nietodCommented:
SISU, have you read the question history?  You can't answer a question unless you've read it!
0
q_lowAuthor Commented:
I'm not looking for a program.
0
q_lowAuthor Commented:
Will these be good specifications?
1. array >0
2. at least there should be one y in the array
3.return array with y's changed with k's
0
nietodCommented:
Number 3 certainly is, that is the point of the program.

Number 1 is debatable.  A 0 length array is, well, not really an array.  Dependign on your algorithm the array length won't matter much.  It depends on other requirements you develope, like up to how long will the file be?  Can it be any length or will there be a maximum length?

Number 2, is debatable again.  Why would you need that restriction? Its like writting a spelling checker and saying it can be used on a document only if there is at least one spelling mistake.  Well the user might not even know if there is a spelling mistake, so how will they know if they can use it?  Ask yourself, is there a good reason for having this restriction?  Maybe there is, I don't see it though..

Things to consider:
Does the program handle files of any length?
Files with any name?
Does it handle both upper and lowercase letters?
Do the files have to be of a certain type?  (Like text files, could they be EXEs)?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
q_lowAuthor Commented:
k thanx
how do I get points or award pints>?
0
nietodCommented:
You need to pick the expert that you think helped the most and either ask them to submit an answer or you can accept one of their comments as an answer (this option appears at the top of the comment box).
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.