By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,458 Members | 1,215 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,458 IT Pros & Developers. It's quick & easy.

Need Help with this Program.

P: n/a
ASSIGNMENT (4) USING AND MANIPUPATING ARRAYS (Chapter 10 material)

For this assignment you are to:

1) Create and manage arrays
a) One of type integers (containing 10 elements).
b) One of type strings (containing 20 elements).
c) One of type char (containing 30 elements).
2) Search them using (linear AND binary) methods.
3) Sort the arrays. (Selection Sort) From CH(10).
4) Display various results from the (searching/sorting) to standard
output.
YOU ARE FREE TO CHOOSE WHATEVER METHODS YOU WANT FOR THE INPUT
(FILE/STANDARD INPUT).
ATHOUGH FILES MAKE FOR EASIER
TESTING.

FOR THE TESTING/SEARCHING OF THE CHAR array, you should
#include<ctype.h>
and calculate the number of letters/digits in the array.

EXAMPLE:
char x[10] = {'A','a','9','~','1','2','3','Z','G','T');
output would be:
5 alpha characters
4 digit characters
1 non-alphanumeric character.
SKELETON CODE:

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

using namespace std;
I dont get this at all. Its for my class, the input can be a file or
just ask when the program is run. the out put can be in a file or on
the screen as well. It doesnt need to sort all three, just one at a
time. I figure the best bet is to do it as three seperate programs?
so that you do one, it outputs it, do another, output it so on so
forth. Can any one get me started on this please.

Nov 27 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
ho********@aim.com wrote:
ASSIGNMENT (4) USING AND MANIPUPATING ARRAYS (Chapter 10 material)

For this assignment you are to:

1) Create and manage arrays
a) One of type integers (containing 10 elements).
b) One of type strings (containing 20 elements).
c) One of type char (containing 30 elements).
2) Search them using (linear AND binary) methods.
3) Sort the arrays. (Selection Sort) From CH(10).
4) Display various results from the (searching/sorting) to standard
output.
YOU ARE FREE TO CHOOSE WHATEVER METHODS YOU WANT FOR THE INPUT
(FILE/STANDARD INPUT).
ATHOUGH FILES MAKE FOR EASIER
TESTING.

FOR THE TESTING/SEARCHING OF THE CHAR array, you should
#include<ctype.h>
and calculate the number of letters/digits in the array.

EXAMPLE:
char x[10] = {'A','a','9','~','1','2','3','Z','G','T');
output would be:
5 alpha characters
4 digit characters
1 non-alphanumeric character.
SKELETON CODE:

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

using namespace std;
I dont get this at all.

Do you know what an array is?
Do you know hwat integers, strings, and chars are?
Do you know what linear and binary search are?
Do you know what selection sort is?

You see unless you say what you are having trouble with it's very hard
to help.
Its for my class, the input can be a file or
just ask when the program is run. the out put can be in a file or on
the screen as well. It doesnt need to sort all three, just one at a
time. I figure the best bet is to do it as three seperate programs?
That sounds reasonable. If you are allowed to write multiple programs
(and I don't see why not) then I think you could easily write 10
programs to cover all the topics above. Makes much more sense than one
huge program to cover everything.
so that you do one, it outputs it, do another, output it so on so
forth.
I'm not really following that.

Can any one get me started on this please.


Take one tiny part of the assignment (start say with reading one of the
arrays from a file), get that working. Then add another small part (say
linear search), get that working, and so on.

It's obvious from the above description that you have a lot of latitude,
you can really do this in about 10,000 different ways, so pick one, and
start programming.

DO IT IN SMALL STEPS.

john
Nov 27 '05 #2

P: n/a
Hi

ho********@aim.com wrote:
1) Create and manage arrays
a) One of type integers (containing 10 elements).
b) One of type strings (containing 20 elements).
c) One of type char (containing 30 elements).
2) Search them using (linear AND binary) methods.
3) Sort the arrays. (Selection Sort) From CH(10).
4) Display various results from the (searching/sorting) to standard
output. [...] I dont get this at all. Its for my class, the input can be a file or
just ask when the program is run. the out put can be in a file or on
the screen as well. It doesnt need to sort all three, just one at a
time. I figure the best bet is to do it as three seperate programs?
so that you do one, it outputs it, do another, output it so on so
forth.
I think it's better to do it in one program, as you'd end up with a lot of
duplicate code otherwise...
Can any one get me started on this please.


You could start reading
http://www.parashift.com/c++-faq-lit...t.html#faq-5.2

cheers
Markus

Nov 27 '05 #3

P: n/a
<ho********@aim.com> wrote:
ASSIGNMENT (4) USING AND MANIPUPATING ARRAYS (Chapter 10 material)

For this assignment you are to:

1) Create and manage arrays
a) One of type integers (containing 10 elements).
b) One of type strings (containing 20 elements).
c) One of type char (containing 30 elements).
2) Search them using (linear AND binary) methods.
3) Sort the arrays. (Selection Sort) From CH(10).
4) Display various results from the (searching/sorting) to standard
output.
YOU ARE FREE TO CHOOSE WHATEVER METHODS YOU WANT FOR THE INPUT
(FILE/STANDARD INPUT).
ATHOUGH FILES MAKE FOR EASIER
TESTING.

FOR THE TESTING/SEARCHING OF THE CHAR array, you should
#include<ctype.h>
and calculate the number of letters/digits in the array.

EXAMPLE:
char x[10] = {'A','a','9','~','1','2','3','Z','G','T');
output would be:
5 alpha characters
4 digit characters
1 non-alphanumeric character.
SKELETON CODE:

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

using namespace std;
I dont get this at all. Its for my class, the input can be a file or
just ask when the program is run. the out put can be in a file or on
the screen as well.
Perhaps so. But what you posted says the output goes to stdout.

It doesnt need to sort all three, just one at a
time. I figure the best bet is to do it as three seperate programs?
so that you do one, it outputs it, do another, output it so on so
forth. Can any one get me started on this please.


I see no advantage to one monolithic program, and no requirement to do so.
So I would opt for three programs. I would certainly get the input from a
file, in the long run there will be a lot less effort. Note the order is
jumbled, you want to sort before you do the binary search, not after.
Nov 28 '05 #4

P: n/a
Im not looking for someone to do the work for me, I just need to know
the thing s for starting arrays, how to do the differnt arrays and the
searchs, I dont know what the things John Harrison says, this is an
intro class and the 3rd project, the book is not specific of this stuff.

Nov 28 '05 #5

P: n/a

ho********@aim.com wrote:
Im not looking for someone to do the work for me, I just need to know
the thing s for starting arrays, how to do the differnt arrays and the
searchs, I dont know what the things John Harrison says, this is an
intro class and the 3rd project, the book is not specific of this stuff.


Tell your teacher you don't understand and ask for help.

Nov 28 '05 #6

P: n/a
ho********@aim.com wrote:
Im not looking for someone to do the work for me, I just need to know
the thing s for starting arrays, how to do the differnt arrays and the
searchs, I dont know what the things John Harrison says, this is an
intro class and the 3rd project, the book is not specific of this stuff.


You need three arrays, here's one of them

int main()
{
int array[10];
...
}

That's an array of ten integers. The other arrays are declared
similarly. If you honestly didn't know how to do that then the rest of
the exercise is going to be way beyond you. You need more help than you
can get from here, ask your teacher.

It's completely ridiculous for you to be expected to do linear search,
binary search and selction sort without having been told anything about
them already, so I would guess there is some misunderstanding somewhere.

john
Nov 28 '05 #7

P: n/a
<ho********@aim.com> wrote:
Im not looking for someone to do the work for me, I just need to know
the thing s for starting arrays, how to do the differnt arrays and the
searchs, I dont know what the things John Harrison says, this is an
intro class and the 3rd project, the book is not specific of this stuff.


There are degrees of knowing almost anything. But if you weren't just being
humble or shy and have no idea what the items in that list were about, you
need a tutor, someone you can talk to at length, at least on the telephone.
You can not expect the instructor to go back over all these things; or get
enough help via.a slow, serial, labor intensive medium such as Usenet.
Nov 28 '05 #8

P: n/a
John Harrison wrote:

It's completely ridiculous for you to be expected to do linear search,
binary search and selction sort without having been told anything about
them already, so I would guess there is some misunderstanding somewhere.


The original spec said that "Chapter 10" explained how to do
selection sort, so I guess it also explains binary search.

Nov 29 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.