473,403 Members | 2,270 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

A question on designing using ADT

24
I know nothing about ADT but I was told to write a program that uses appropriate ADT used to provide the various functions needed. In particular, to develop 3 files, assuming that ADT is called Moss:
1. Moss.h // the header file
2. Moss.cpp // the implementation file
3. useMoss.cpp // The file containing the main() that will handle the input, calling various functions implemented, and output the
required information.

Sample Input:
File 1 File 2 Lines Matched
File1-0(71%) File2-0(63%) 177
File1-1(59%) File2-1(63%) 167
File1-2(49%) File2-2(54%) 101
File1-3(42%) File2-3(51%) 130
File1-4(53%) File2-4(47%) 92

Sample Output:
number of records: 19
maxp1 = 71 minp1 = 13 avgp1 = 35 stdevp1 = 19
maxp2 = 63 minp2 = 10 avgp2 = 36 stdevp2 = 19
maxnline = 183 minnline = 20 avgnline = 83 stdevnline = 50

Explanation of the output:
The statistics tells us that there are 19 records, the maximum p1 is 71%, minimum p1 13%, average p1 35%, and the
standard deviation of p1 is 19%. The next line is for p2 and the last line is for the number of lines found similar.

Can anyone help me atleast to get me started by showing me how do i get about doing this program... Thanks so much... :> I desperately need help in programming...
Sep 2 '06 #1
9 3153
Banfa
9,065 Expert Mod 8TB
I am afraid I don't see the corrolation between input and output.

an ADT (abstracted data type) is a method where you put your data into a separate file and rather than access it directly you write a set of functions to access an manipulate it. Then the external code just calls the functions rather than accessing the data directly.
Sep 2 '06 #2
Nhd
24
I am afraid I don't see the corrolation between input and output.

an ADT (abstracted data type) is a method where you put your data into a separate file and rather than access it directly you write a set of functions to access an manipulate it. Then the external code just calls the functions rather than accessing the data directly.
Hi... I didnt actually paste the whole question in... Maybe thats y u cant see any correlation between the input and the output...

This is the actual question:

Sample Input:
File 1 File 2 Lines Matched
File1-0(71%) File2-0(63%) 177
File1-1(59%) File2-1(63%) 167
File1-2(49%) File2-2(54%) 101
File1-3(42%) File2-3(51%) 130
File1-4(53%) File2-4(47%) 92
File1-5(58%) File2-5(57%) 109
File1-6(43%) File2-6(48%) 183
File1-7(48%) File2-7(50%) 80
File1-8(38%) File2-8(45%) 81
File1-9(40%) File2-9(41%) 71
File1-10(38%) File2-10(32%) 64
File1-11(17%) File2-11(29%) 61
File1-12(28%) File2-12(26%) 65
File1-13(22%) File2-13(18%) 50
File1-14(13%) File2-14(11%) 20
File1-15(16%) File2-15(14%) 28
File1-16(17%) File2-16(16%) 34
File1-17(14%) File2-17(13%) 23
File1-18(14%) File2-18(10%) 41

Sample Output:
number of records: 19
maxp1 = 71 minp1 = 13 avgp1 = 35 stdevp1 = 19
maxp2 = 63 minp2 = 10 avgp2 = 36 stdevp2 = 19
maxnline = 183 minnline = 20 avgnline = 83 stdevnline = 50

I hope ur able to see the correlation now... This program is really complex and I hav no idea abt ADT... I hope ur able to help....
Sep 3 '06 #3
D_C
293 100+
I believe I understand the problem now. It has a lot to do with statistics. Each file has a companion file, for example, File1-13 and File2-13. They each have some number of lines, not necessarily the same. The lines are then compared and see how many match. I'm not sure if this is done line by line, or by using an algorithm to minimize the differences.

After this is done for all files that follow the naming convention, some statistics are computed. Max, min, avg and stdev refer to the maximum, minimum, average, and standard deviation, respectively. 'p' is for percent, and 1 or 2 is for File1 or File2, respectively. 'nlines' is for the number of lines (per file), this probably counts both sets of files.

For example, avgp2 = 36 means that on average, 36% of the lines in File2* had matching lines in their companion file.

1. Find all files that fit the naming scheme
2. Open each file and it's companion
3. Compare each file, line by line or by algorithm.
4. For each file, record the number of lines total, and the number of lines matched.
5. Calculate the statistics, based on the recorded data for each file.
6. Print the results
Sep 3 '06 #4
Nhd
24
I believe I understand the problem now. It has a lot to do with statistics. Each file has a companion file, for example, File1-13 and File2-13. They each have some number of lines, not necessarily the same. The lines are then compared and see how many match. I'm not sure if this is done line by line, or by using an algorithm to minimize the differences.

After this is done for all files that follow the naming convention, some statistics are computed. Max, min, avg and stdev refer to the maximum, minimum, average, and standard deviation, respectively. 'p' is for percent, and 1 or 2 is for File1 or File2, respectively. 'nlines' is for the number of lines (per file), this probably counts both sets of files.

For example, avgp2 = 36 means that on average, 36% of the lines in File2* had matching lines in their companion file.

1. Find all files that fit the naming scheme
2. Open each file and it's companion
3. Compare each file, line by line or by algorithm.
4. For each file, record the number of lines total, and the number of lines matched.
5. Calculate the statistics, based on the recorded data for each file.
6. Print the results

Hi thanks for the info... But i'm still facing problems as in i cant really understand how do i go abt doing this... this is a very tough assignment and i cant handle this... :(
Sep 4 '06 #5
Nhd
24
Expand|Select|Wrap|Line Numbers
  1.  #include <iostream> 
  2. #include <string>
  3. #include <sstream>
  4. #include "Moss.h"
  5. using namespace std;
  6.  
  7. int main() {
  8.  
  9. int i=0;
  10. string oneline, sentence; 
  11.  
  12. cout<<"File1" << " " << "File2" << " " << "Lines Matched" << endl; 
  13. cin>>sentence;
  14. i++;
  15.  
  16. while(getline(cin,oneline))
  17. {
  18. istringstream is(oneline);
  19. while (is>>oneline)
  20. {
  21. i++;
  22. }
  23. }
  24. cout<<"number of records: "<<i<<endl;
  25.  
  26. system("pause");
  27.     return 0;
  28. }
  29.  
Hi, actually im supposed to type in a number of lines and then count the number of lines/sentences... However, my program above only counts the number of words that i type in and not how many sentences... Can anyone check the program for me... Please help me.... thks...
Sep 4 '06 #6
D_C
293 100+
I suggest you tackle problem #1 first, then #2, ... and finally #6. Here's some information on #1.

The FindFirstFile function opens a search handle and returns information about the first file whose name matches the specified pattern. Once the search handle is established, you can use the FindNextFile function to search for other files that match the same pattern. When the search handle is no longer needed, close it by using the FindClose function.
If you only want to count the lines, then replace
Expand|Select|Wrap|Line Numbers
  1. while(getline(cin,oneline))
  2. {
  3.   istringstream is(oneline);
  4.   while (is>>oneline)
  5.   {
  6.     i++;
  7.   }
  8. }
with
Expand|Select|Wrap|Line Numbers
  1. while(getline(cin,oneline))
  2.   i++;
Your code divided it into lines, then into words, and counted each word instead of dividing it into lines and counting each line.
Sep 4 '06 #7
Nhd
24
hi D_C...

I tried that before but it still doesnt count the number of lines...
when i type in File1-0(71%) File2-0(63%) 177, it reads as 2... i have no idea why... shouldn't it read as 1 as i input only 1 sentence... please help me to rectify this problem... thanks so much
Sep 4 '06 #8
dude... look through your code.. you have an extra "i++;" before your while loop. This is why your record shows an extra line. Now that is solved..
Let me elaborate on your other problem since I have a similar problem.

Sample Input:
File 1 File 2 Lines Matched
File1-0(71%) File2-0(63%) 177
File1-1(59%) File2-1(63%) 167
File1-2(49%) File2-2(54%) 101
File1-3(42%) File2-3(51%) 130
File1-4(53%) File2-4(47%) 92

If i wished to extract certain information from the above input, for eg. from the first line: File1-0(71%) File2-0(63%) 177
I wish to extract the info "71", "63" and "177" and store them in 3 separate integer arrays before incrementing the array and moving onto the next line. How would I go about doing that?
Sep 5 '06 #9
D_C
293 100+
I just answered a similar question in the thread How to get individual information from a file.
Sep 5 '06 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: E G | last post by:
Hi! I am having problems in designing a class. First, I have a base class that allocates a 3D data set and allows some other mathematical operations with it, something like this: template...
12
by: James Brown | last post by:
Hi all, Having problems designing a template-class. I'll describe my scenario first then show what I've come up with so far: Need a class to provide pointer/array-like access to an area of...
6
by: Darren | last post by:
X-No-Archive Hi all, Can anyone help me with structuring the data in a small tool I have to build? I'm trying to work out if there's a design pattern or data structure that would remove some...
6
by: Gary James | last post by:
This may not be a direct C# question, but since I'll be using using C# for development, I thought I'd pose the question here. I'll soon be involved in the design of a new software product that...
2
by: Sky Sigal | last post by:
Hello: I'm currently messing around, and need as much feedback/help as I can get, trying to find the most economical/graceful way to build usercontrols that rely on styling to look any good... ...
7
by: dad | last post by:
REQ: any utilities for designing front-ends for databases
3
by: mystilleef | last post by:
Hello, I need to design a plug-in system for a project. The goal is to allow third party developers interact with an application via plug-ins in a clean and robust manner. At this point I am...
8
by: pransri2006 | last post by:
Hi guys! I think all of u know about the designing of compilers. Can any body tell me about the designing of the compilers. And also tell me the difference between the compilers and Interpreter...
1
by: anujaf | last post by:
I'm a VB 6 programmer. I want jump to Web designing. I would like to know what is the best web designing tool which can be intergrated with the ASP .net and what is the best book to learn web...
0
by: anujaf | last post by:
I'm a VB 6 programmer. I want jump to Web designing. I would like to know what is the best web designing tool which can be intergrated with the ASP .net and what is the best book to learn web...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.