7 Replies - 667 Views - Last Post: 05 August 2009 - 08:42 AM Rate Topic: -----

#1 Dlo0o3a  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 31-July 09

I need your help in C++ assignment

Posted 04 August 2009 - 09:59 AM

You are working for your state’s motor vehicle registry, and it has been discovered that some people in the driver’s license database have multiple records. The license records are stored in alphabetical order on a set of files, one per letter in the alphabet. The first file is licenses_a.txt, and the last file is licebses_z.txt. The files differ in size, with the first line of each file being an integer that specifies the number of records in the file. Each record consists of a license number (integer), and driver’s name (string). See Figure 1 for a sample input file. Each record should be represented as a struct with the above mentioned members. To find the duplicates, each file needs to be sorted into order of license number. To do this, change the SortedList class ) so that the list array is dynamically created to be the necessary length for the data on the particular file. Each component of the list will be a license struct type. Use the SortedList functions to read the data from a file and count the number of duplicate records discovered. Then output this count to an output file called duplicates_X.txt where X is the same letter of the input file (e.g. If the input file was licenses_a.txt then the output file is duplicates_a.txt). Finally, restart the scanning of the list from the beginning and output the number of duplicate records and the first occurrence of duplicated record to the output file in alphabetical order along with the number of times it is duplicated. A sample output file is shown in Figure 2.
Your program should be able to automatically process all the 26 input data files (one file for each letter). Remember to delete the dynamic variables and close all the files as soon as they are not needed in your program. A summary of the processing should be output to the screen as shown in Figure



9
3456789 Aamna Ali
4567891 Adnan Khalid
1234567 Ahmed Salim
1234567 Ahmid Salim
3456789 Amna Ali
9876543 Amar Rashid
9876543 Ammar Rashid
9876543 Ammar rashed
9638527 Azzam Nasser
Figure 1: sample input file
Figure 3: sample run of the program.
4
1 3456789 Aamna Ali
1 1234567 Ahmed Salim
2 9876543 Amar Rashid
Figure 2: sample output file



I need help in this assigmnt in sorted list

# include "List.h"

List::List() {
	for (int i=0;i<MAX_SIZE; i++)
		data[i] = 0;
	
	length = 0;
	pos = -1;
}

bool List::isEmpty () const {	
	return length>0?true:false;
}

bool List::isFull () const {
	return length==MAX_SIZE?true:false;
}

int List::getLength () const {
	return length;
}

void List::insertItem(ItemType item) {
	pos++;
	data[pos] = item;
	length ++;
}

void List::deleteItem (ItemType item) {
	for (int i=0; i<length; i++) {
		if (data[i] == item) {
			if (length >1)
				data[i] = data[length-1];
			length--;
			break;
		}
	}
}

void List::sort () {
	// code this function
	
}

ItemType List::getNextItem () {
	ItemType item;
	// code this function
	
	return item;
}



Place can you help what wrong???

Is This A Good Question/Topic? 0
  • +

Replies To: I need your help in C++ assignment

#2 sparkart  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 113
  • View blog
  • Posts: 691
  • Joined: 16-February 09

Re: I need your help in C++ assignment

Posted 04 August 2009 - 10:14 AM

Let me get you started:
struct License
{
	int number;
	std::string name;

	License(int num, std::string name): number(num), name(name) {}
};



Now you'll need a LoadFile method that does the following:
-Load file.
-Read first line (the integer).
-Push_back struct containing the data.
-Sort the list (using the element's number member)once the file has been completely read.
Was This Post Helpful? 0
  • +
  • -

#3 Arenlor  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 34
  • View blog
  • Posts: 389
  • Joined: 26-April 06

Re: I need your help in C++ assignment

Posted 04 August 2009 - 10:22 AM

[rules][/rules]
Was This Post Helpful? 0
  • +
  • -

#4 Dlo0o3a  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 31-July 09

Re: I need your help in C++ assignment

Posted 04 August 2009 - 10:49 AM

than for help but I need more help in coding this assignment
Was This Post Helpful? 0
  • +
  • -

#5 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6110
  • View blog
  • Posts: 23,667
  • Joined: 23-August 08

Re: I need your help in C++ assignment

Posted 04 August 2009 - 02:23 PM

Are you receiving any errors? Does this code not work that way you intended it? When asking for help there are a couple items that are vital in order for someone to properly help you:
  • Post the code you're having problems with
  • Post the exact error you're receiving, if you are receiving one
  • If no error explain what the code is doing versus what you want it to do
  • Post your question in the body of your post, not the description field

Was This Post Helpful? 0
  • +
  • -

#6 Arenlor  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 34
  • View blog
  • Posts: 389
  • Joined: 26-April 06

Re: I need your help in C++ assignment

Posted 04 August 2009 - 07:45 PM

Also, what's in List.h
If you need help please post the FULL code so that we can see any possible bugs.
Was This Post Helpful? 0
  • +
  • -

#7 Dlo0o3a  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 31-July 09

Re: I need your help in C++ assignment

Posted 05 August 2009 - 07:33 AM

\Place help me in conect sturct with class and main funcation

the submissions today :angry:

View PostArenlor, on 4 Aug, 2009 - 06:45 PM, said:

Also, what's in List.h
If you need help please post the FULL code so that we can see any possible bugs.





This the List.h

typedef int ItemType;

const int MAX_SIZE = 100;

class List {
private:
	ItemType data[MAX_SIZE];
	int length;
	int pos;

public:
	List();
	bool isEmpty() const;
	bool isFull () const;
	bool IsPresent (ItemType item) const;
	int getLength() const;


	void insertItem(ItemType);
	void deleteItem(ItemType);
	
	void sort();
	ItemType getNextItem();
};

Was This Post Helpful? 0
  • +
  • -

#8 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6110
  • View blog
  • Posts: 23,667
  • Joined: 23-August 08

Re: I need your help in C++ assignment

Posted 05 August 2009 - 08:42 AM

This looks like what was likely given to you by the professor. What have *you* done. We're *not* going to do your homework for you.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1