C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old June 29th, 2009, 08:36 AM
dody_16 dody_16 is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jun 2009
Posts: 1 dody_16 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 2 m 53 sec
Reputation Power: 0
Plz i want help so fasttttt

hi alll
i have to present my project tomorrow
pla i cant dothis project completely can any one give me simple ideas
am in trouble
the program:
you are required to design a c++ program for a company management by using c++,structures ,and arrays. you should record the following data in two arrays
1- employee id ,employee name,working days,daily wage
2-department id,department name
the program should contain
1-add department
reads from user department data and store ir
2-add employee
read employee data from user and department id he working n it and store it
3 -salary calculation
read dep id
calculate net salary for all emp in this depart
salary =(working days*daily wage)-10%tax
>>>>>>>>>>>>>>>>>>>>>>>>>>
my first attempt
#include<iostream.h>
#include<string>
using namespace std;
struct emp{
int emp_id;
string emp_name;
int w_D;
int daily_wage;
int dept_id;
};
struct dept{
int dept_id;
string dep_name;
};


void add ()
{

int id;
cin>>id;
for(int i =0;i<=100;i++)
cin>>dept[i].dept_id;
if(dept[i].dept_id==id)
{ cout<<"this ID exists...please enter a valid one ";
i--;
continue;}
else
cin>>dept[i].dept_id;}
for(int i=0;i<=100;i++)
cout<<dept[i].dept_id<<endl;


thxxxxxxx allllllllllllllllllllllll
plz help me

Reply With Quote
  #2  
Old July 1st, 2009, 03:16 PM
larssss larssss is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2009
Posts: 30 larssss User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 54 m 18 sec
Reputation Power: 1
Cool It should be something like this...

This is a huge task to do all in one program but.. i did it for you...
only took me 2 hours though..
Code:
#include <iostream>
#include <string>
#include <vector>
#include <fstream>

using namespace std;

bool reading = true;
vector <string> R;
void StringExplode(string str, string separator, vector<string>* results);
void add_user(string emp_name, int w_D, int daily_wage, int dept_id, int dept_id2, string dep_name);
string line;
int i;
struct emp{
       int emp_id;
       string emp_name;
       int w_D;
       int daily_wage;
       int dept_id;
};

struct dept{
       int dept_id;
       string dep_name;
};

emp employee[1000000];
dept department[1000000];
int employees;
string input;
int main(){
    getline(cin, input);
    R.clear();
    StringExplode(input, " ", &R);
    if(R[0] == "add" || R[0] == "ADD"){
            add_user(R[1], atoi(R[2].c_str()), atoi(R[3].c_str()), atoi(R[4].c_str()), atoi(R[5].c_str()), R[6]);
            cout << "Added employee " << R[1] << endl;
    }
    if(R[0] == "view" || R[0] == "VIEW"){
            i = 0;
          fstream saved_r("saved_employees.dat", ios::in | ios::binary);
          cout << "Loading employee list" << endl;
          while(reading == true && saved_r.eof() == false){
                R.clear();
                getline(saved_r, line);
                StringExplode(line, " ", &R);
                if(line.length() > 0){
                      employee[i].emp_id = atoi(R[0].c_str());
                      employee[i].emp_name = R[1];
                      employee[i].w_D = atoi(R[2].c_str());
                      employee[i].daily_wage = atoi(R[3].c_str());
                      employee[i].dept_id = atoi(R[4].c_str());
                      department[i].dept_id = atoi(R[5].c_str());
                      department[i].dep_name = R[6];
                      
                      cout << "Employee id: ";
                      cout << employee[i].emp_id << endl;
                      cout << "Employee name: ";
                      cout << employee[i].emp_name << endl;
                      cout << "Employee workdays: ";
                      cout << employee[i].w_D << endl;
                      cout << "Employee daily wage: ";
                      cout << employee[i].daily_wage << endl;
                      cout << "Employee department id: ";
                      cout << employee[i].dept_id << endl;
                      cout << "Employee department id2: ";
                      cout << department[i].dept_id << endl;
                      cout << "Employee department name: ";
                      cout << department[i].dep_name << endl;
                      cout << "-10% tax: " << (employee[i].w_D * employee[i].daily_wage) - ((employee[i].w_D * employee[i].daily_wage) * 10) / 100;
                      cout << endl;
                      
                 }
          if(line.length() <= 0){
                reading = false;
          }
          line.clear();
          R.clear();
          i++;
    }
    saved_r.close();
    employees = i;
    cout << employees << " Employees" << endl;
    cout << "OK \n";
 }
    system("PAUSE");
    return 0;
}



void StringExplode(string str, string separator, vector<string>* results){
    int found;
    found = str.find_first_of(separator);
    while(found != string::npos){
        if(found > 0){
            results->push_back(str.substr(0,found));
        }
        str = str.substr(found+1);
        found = str.find_first_of(separator);
    }
    if(str.length() > 0){
        results->push_back(str);
    }
    if(str == ""){
           results->push_back("Nothing here");
           results->push_back("Nothing here");
           results->push_back("Nothing here");
           results->push_back("Nothing here");
           results->push_back("Nothing here");
           results->push_back("Nothing here");
           results->push_back("Nothing here");
           results->push_back("Nothing here");
           results->push_back("Nothing here");
           results->push_back("Nothing here");
    }
    if(!found > 0){
              results->clear();
    }
}

void add_user(string emp_name, int w_D, int daily_wage, int dept_id, int dept_id2, string dept_name){
           i = 0;
     fstream saved_w("saved_employees.dat", ios::out | ios::app);
     employees++;
     employee[employees].emp_id = employees;
     employee[employees].emp_name = emp_name;
     employee[employees].w_D = w_D;
     employee[employees].daily_wage = daily_wage;
     employee[employees].dept_id = dept_id;
     department[employees].dept_id = dept_id2;
     department[employees].dep_name = dept_name;
     
     saved_w << employee[employees].emp_id;
     saved_w << " ";
     saved_w << employee[employees].emp_name;
     saved_w << " ";
     saved_w << employee[employees].w_D;
     saved_w << " ";
     saved_w << employee[employees].daily_wage;
     saved_w << " ";
     saved_w << employee[employees].dept_id;
     saved_w << " ";
     saved_w << department[employees].dept_id;
     saved_w << " ";
     saved_w << department[employees].dep_name;
     saved_w << "\n";
     saved_w.close();
     
}
 :rockon: 

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > Plz i want help so fasttttt


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

Request Your Free Technology Downloads!
 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

Request Your Free Technology Downloads!
 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

Request Your Free Technology Downloads!
 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

Request Your Free Technology Downloads!
 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
Stay green...Green IT