Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Project Need Help!!! Due May 6- Char arrays and sorting
Index -> Programming, C++ -> C++ Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
simpleerob




PostPosted: Fri Apr 30, 2004 10:25 am   Post subject: Project Need Help!!! Due May 6- Char arrays and sorting

My compiler is pico ---- .cpp
Hi I need help with my term project: I have gotten an out put, but I don't think I formated the program correctly according to the question. If Any one can help me please write back soon, b/c its due thursday May 6th. Here's the question:

You have the following clients for your consulting firm:
Client -----------------------------------Business Type

Acme Construction --------------------Machinery design
Johnson Electrical ---------------------Switch manufacturing
Brown Heating and Cooling --------- Boiler design
Smith Switches -----------------------Switch manufacturing
Jones Computers ---------------------Computer sales
Williams Cleaning Equipment --------Machinery sales


To keep track of your clients in an orderly manner, you need a program that can arrange them alphabetically be name or business type. Write such a program using a bubble sort. The input specifications are to read the client and business from a file. Read the requirement of sorting according to a name or business from the key board. The output specifications is to put the arranged list into an output file.


Heres what I have so far:

code:

#include <iostream>
#include <fstream>
using namespace std;
int main ()
{

const int Num_Rows = 6, Num_cols= 800, LINE =100;
char aa[Num_Rows], bb[Num_cols], cc[6] [LINE];
ifstream infile ("term.dat");
int i;

cout<<"Data items in original order:\n";
cout<<"Client                           Business Type"<<endl<<endl;


for (i=0; i<=6; i++)
{
infile.getline(cc[i],
sizeof (cc[i]));
cout<<cc[i]<<endl;
cout<<"Data items after sort:\n";

}
}


Here's my results

Data items in original order:

Client ----------------------------------Business Type

Acme Construction -------------------Machinery design
Johnson Electrical --------------------Switch manufacturing
Brown Heating and Cooling ---------Boiler design
Smith Switches -----------------------Switch manufacturing
Jones Computers --------------------Computer sales
Williams Cleaning Equipment -------Machinery sales


Here's my question: I don't understand how to read the data file and sort an array of characters using bubble sort. How can I make an 2 -D array of characters and sort it alphabetically be the name using bubble sort? I don't know if i'm doing the program correctly. I need someone to help me write the program correctly. Please write back soon because its due May 6 th.
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> Programming, C++ -> C++ Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 1 Posts ]
Jump to:   


Style:  
Search: