الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

I need ur help

مغلق
بدأه نورالعراقي في 1 يناير 2007 · 5 رد · 627 مشاهدة · في الأسئلة المجابة
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم

اواجه صعوبه في اتمام اسايمنت بلغه السي ارجو منكم المساعده

الموضوع:

A company offers a loan for its employees .the company ranking the employees from rank 6 for beginners (as the lowest rank) to rank 1 for seniors (as the highest rank). The company applies pre-conditions to enable employees to get the loan. These conditions are :

1-the maximum amount of loan allowed must not exceed 3 times the salary.

2-the minimum rank of employee must be 4.

The deduction amount is calculated depending on the salary and the rank of the employee. The deduction policy is as follows:

Rank of employee deduction

1 salary*5%

2 salary*4%

3 salary *3%

4 salary*2%

the company needs to implement a menu-driven program to store and display information about the loan of its employees.

1-A menu structure should be implemented which contains the following menu items

A-add information of a new employee

B-display employee information.

C-display all employees information

D-exit system

2- a function to input the detailed information of a new employee of the company and stores it in employee file. The information is:

 Employee number

 Employee name

 Employee salary

 Employee rank

3-function to display employee information.

4- function to all employees information in the company

The menu structure should be updated to include the following entries.

A-enter loan details

B-answer queries

C-display report

5-a function to input information about the employee loan. store the information in the loan file if an employee satisfy the pre-conditions of the loan, otherwise do not store it and display a massage to inform the employee. The information is:

 Employee number

 Amount of the loan

 Date of the loan

6-a function to calculate the deduction amount depending on the salary and rank of the employee and store it in the loan file

7- a function to answer the following queries:

a- how many employees get a loan

b- is an employee have a loan or not

c-what is the total amount of deductions

8-a function to display a loan report containing the following information:

 Employee number

 Employee name

 Amount of the loan

 Deduction amount

وهذي محاولتي فيه:

#include <stdio.h>

void main()

{

int request;

void add_new_employee();

void disp_employee_info();

void disp_all_employees_info();

void Exit_system();

/* display Menu options */

printf("Please select one of the following options:\n");

printf("1 - Add Information of a new employee\n");

printf("2 - Display an Employee Information\n");

printf("3 - Display all Employees Information\n");

printf("4 - Exit System\n");

scanf("%d", &request);

/* Processing user's request */

while (request !=4) {

switch (request) {

case 1:

/* function to add information of an new employee */

add_new_employee();

break;

case 2:

/* function to display an employee information */

disp_employee_info();

break;

case 3:

/* function to display all employees information */

disp_all_employees_info();

break;

default:

/* wrong data entry for menu item selection */

printf("Invalid Option ... try again");

}

}

/* End of Program */

}

void add_new_employee(EmplNo,EmplName,EmplSalary,EmplRank);

{

int EmplNo;

char EmplName[30];

double EmplSalary;

int EmplRank;

char MoreEmpl='y';

FILE *cfptr;

if ((cfptr=fopen("Employees.dat","a"))==NULL)

{

printf("Can not open file\n");

} // end if

else {

while (MoreEmpl !='n');

{

printf ("Enter Employee Number, Employee Name, Employee Salary, Employee RankCode\n");

scanf("%d %s %lf %d",&EmplNo,EmplName,&EmplSalary,&EmplRank);

fprintf(cfptr,"%d %s %lf %d\n",EmplNo,EmplName,EmplSalary,EmplRank);

printf ("Do you want anther Employee");

scanf("%s",&MoreEmpl);

}

fclose(cfptr);

} // end else

} // end add_new_employee function

void disp_employee_info()

{

FILE *fptr;

int empno;

char empname[30];

double empsalary;

int emprank;

char seemore='y';

int eno;

if ((fptr=fopen("employees.dat","r"))==NULL) {

printf("Error in opening Employee File for reading employees information\n");

}

else {

while (seemore=='y' || seemore=='Y')

{

rewind(fptr);

printf("Enter Employee Number to display employee information ");

scanf("%d\n",&eno);

while ( !feof(fptr))

{

fscanf(fptr,"%d %s %lf %d\n",&empno,empname,&empsalary,&emprank);

if (empno == eno) {

printf("Employee Number : %d\n", empno);

printf("Employee Name : %s\n", empname);

printf("Employee Salary: %lf\n",empsalary);

printf("Employee Rank : %d\n",emprank);

break; }

}

printf("Do you wish to see another employee information [Y/N]: ");

scanf("%c",&seemore);

}

}

fclose(fptr);

}

void disp_all_employees_info()

{

FILE *fptr;

int empno;

char empname[30];

double empsalary;

int emprank;

if ((fptr=fopen("employees.dat","r"))==NULL) {

printf("Erron in opening Employee File for reading employees information\n");

}

else {

while ( !feof(fptr))

{

fscanf(fptr,"%d %s %lf %d\n",&empno,empname,&empsalary,&emprank);

printf("Employee Number : %d\n", empno);

printf("Employee Name : %s\n", empname);

printf("Employee Salary: %lf\n",empsalary);

printf("Employee Rank : %d\n",emprank);

}

fclose(fptr);

}

}

#2

السلام عليكم ورحمة الله وبركاته

أخى هذا حل مشكلتك أما عن إضافة التقارير والخصم على المرتب فأنت حاول وأكتب محاولتك وأنا بأذن الله هساعدك فى حل مشكله أنا والأخوة فى المنتدى تفضل:

#include <stdio.h>

void add_new_employee();
void disp_employee_info();
void disp_all_employees_info();


void main()
{
int request, loop;

/* display Menu options */
printf("Please select one of the following options:\n");
printf("1 - Add Information of a new employee\n");
printf("2 - Display an Employee Information\n");
printf("3 - Display all Employees Information\n");
printf("4 - Exit System\n");
scanf("%d", &request);

/* Processing user's request */
if (request ==1)
{
	 add_new_employee();
}

else if (request == 2)
{
	disp_employee_info();
}
else if (request == 3)
{
	disp_all_employees_info();
}
else if (request == 4)
{
   for(loop=0;loop==10050;loop++)
	 {
		clrscr();
		printf("\tsalam");
		exit(1);
	}
}
else
{
printf("Invalid Option ... try again");
}

}




void add_new_employee()
{

int EmplNo;
char EmplName[30];
double EmplSalary;
int EmplRank;
char MoreEmpl='y';
FILE *cfptr;


cfptr=fopen("Employees.dat","a");
printf("Enter Employee Number, Employee Name, Employee Salary, Employee RankCode\n");
scanf("%d\n %s\n  %lf %d",&EmplNo,EmplName,&EmplSalary,&EmplRank);
fprintf(cfptr,"Employee number:%d\n Employee name:%s\n Employee salary:%lf\n Employee rank:%d\n",EmplNo,EmplName,EmplSalary,EmplRank);
printf ("Do you want anther Employee");
scanf("%s",&MoreEmpl);
fclose(cfptr);

}



void disp_employee_info()
{
FILE *fptr;
int empno;
char empname[30];
double empsalary;
int emprank;
int eno;


fptr=fopen("employees.dat","r");
rewind(fptr);
printf("Enter Employee Number to display employee information ");
scanf("%d\n",&eno);


fscanf(fptr,"Employee number:%d\n  Employee name :%s\n Employee salary: %lf\n  Employee rank :%d\n",&empno,empname,&empsalary,&emprank);
printf("Employee Number : %d\n", empno);
printf("Employee Name : %s\n", empname);
printf("Employee Salary: %lf\n",empsalary);
printf("Employee Rank : %d\n",emprank);




fclose(fptr);
}




void disp_all_employees_info()
{
   system("type e:\\c\\employee.dat");
}

أرجو أن أكون أفدتك

سلام

ونسيت ال path اللى فى أخر الكود تحط فيه باص ال employee.dat

befor any great jop there is a bad jop had done

#3

شكرا اخي say say not know للمرور على الموضوع

ولكن اتمنى ان تكمل لي البروجرام لان المشكلة لدي في ال functions الاخيرات كذلك في طريقة عمل الفايل

تشكرات لك مرة اخر

سلام

#4

السلام عليكم ورحمة الله وبركاته

تفضل أخى برنامجك بصراحة أنا عملته من أول وجديد

#include <stdio.h>

void add_new_employee();
void disp_employee_info();
void disp_all_employees_info();


void main()
{
int request, loop;

/* display Menu options */
printf("Please select one of the following options:\n");
printf("1 - Add Information of a new employee\n");
printf("2 - Display an Employee Information\n");
printf("3 - Display all Employees Information\n");
printf("4 - Exit System\n");
scanf("%d", &request);

/* Processing user's request */
if (request ==1)
{
	 add_new_employee();
}

else if (request == 2)
{
	disp_employee_info();
}
else if (request == 3)
{
	disp_all_employees_info();
}
else if (request == 4)
{
   for(loop=0;loop==10050;loop++)
	 {
		clrscr();
		printf("\tsalam");
		exit(1);
	}
}
else
{
printf("Invalid Option ... try again");
}

}




void add_new_employee()
{

int EmplNo, total;
int EmplRank1,num;


char EmplName[30];
double Emp1Salary;
char MoreEmpl='y';
FILE *cfptr, *cfptr2;




cfptr=fopen("Employees.dat","a");
system("time>data.dat");
printf("Enter Employee Number, Employee Name, Employee Salary, Employee Rank\n");
scanf("%d\n %s\n  %lf\n %d\n",&EmplNo,&EmplName,&Emp1Salary,&EmplRank1);
if(EmplRank1==1)
num = 5;
if(EmplRank1==2)
num = 4;
if(EmplRank1==3)
num = 3;
if(EmplRank1==4)
num = 2;

total = Emp1Salary * num / 100;


fprintf(cfptr,"Employee number:%d\n Employee name:%s\n Employee salary:%lf\n Employee rank:%d\n",EmplNo,EmplName,Emp1Salary,EmplRank1);
scanf("%s",&MoreEmpl);
if(MoreEmpl == 'y' || MoreEmpl == 'Y')
{
  add_new_employee();
}
fclose(cfptr);



total = Emp1Salary * num / 100;

cfptr2=fopen("employee2.dat", "a");
fprintf(cfptr2,"\nLoan Size: %f\n Loan Deduction: %d\n",Emp1Salary*3, total);
printf("add now...");
fclose(cfptr2);
if(MoreEmpl != 'y' || MoreEmpl != 'Y')
{
 exit();
}

}




void disp_employee_info()
{
FILE *fptr, *fptr2;
int empno, loandeduction, loansize, reply;
char empname[30];
double empsalary;
int emprank, total, num;
int eno, ds_tk;


fptr=fopen("employees.dat","r");
rewind(fptr);
printf("Enter Employee Number to display employee information ");
scanf("%d\n",&eno);


fscanf(fptr,"Employee number:%d\n  Employee name :%s\n Employee salary: %lf\n  Employee rank :%d\n Loan Size:%d\n ",&empno,empname,&empsalary,&emprank,&loansize);
if(emprank==1)
num = 5;
if(emprank==2)
num = 4;
if(emprank==3)
num = 3;
if(emprank==4)
num = 2;
total = empsalary * num / 100;
printf("Employee Number : %d\n", empno);
printf("Employee Name : %s\n", empname);
printf("Employee Salary: %lf\n",empsalary);
printf("Employee Rank : %d\n",emprank);
printf("Loan Size: %d\n", loansize);

fptr2=fopen("employee2.dat", "a");
fscanf(fptr2,"Employee Deduction:%d ", &loandeduction);
printf("Employee Deduction: %d", total);
fclose(fptr2);

printf("\n\n\n\n\tReply on your Questions(press 1\n");
scanf("%d", &reply);
getchar();

if(reply == 1)
{
 printf("\n\tDisplay Employees them not take tht Loan(press 2)");
 scanf("%d", &ds_tk);
  if(ds_tk == 2)
  {
	disp_employee_info();
  }
}





fclose(fptr);
}




void disp_all_employees_info()
{
   system("type employee.dat");
}

هقولك حاجة أخى متقولى الشركة اللى أنت متفق معاها تسلمها البرنامج وأنا أسلمها البرنامج ;) (بهزر)

أنا أكتفى بالدعاء لى ولوالدى بالرحمة والمغفرة والهداية

وأرجو أن أكون قدمت لك ما تشاء

سلام

befor any great jop there is a bad jop had done

#5

تسلم اخي say say not know ماعليك قصور .والله لو ع الشركه انت اولا لكن هذا اسايمنت مطلوب من قبل الدكتور .

انا اطلعة على البروجرام لكن لحظه انك لم تكمل البروجرام فالبرنامج له تكمله

The menu structure should be updated to include the following entries.

A-enter loan details

B-answer queries

C-display report

5-a function to input information about the employee loan. store the information in the loan file if an employee satisfy the pre-conditions of the loan, otherwise do not store it and display a massage to inform the employee. The information is:

 Employee number

 Amount of the loan

 Date of the loan

6-a function to calculate the deduction amount depending on the salary and rank of the employee and store it in the loan file

7- a function to answer the following queries:

a- how many employees get a loan

b- is an employee have a loan or not

c-what is the total amount of deductions

8-a function to display a loan report containing the following information:

 Employee number

 Employee name

 Amount of the loan

 Deduction amount

هذا بلاظافه انه لما اعمل رن للبرنامج يعطيني 3اخطا و3 ورننج.

فاذا تكرمت تعيد النظر فيه

تشكرات:

#6

السلام عليكم ورحمة الله وبركاته

أخى أنا ضايف فيه حساب قيمة القرض والخصم وكذلك عرض التقرير ولكن نسيت أكتب أمر عرض التاريخ والحمد لله تم الأمر

أما بالنسبة للأخطاء أنا لصقه بعد ما جربته وجربته دلوقتى تانى ومفيش أى خطا فيبدو أنك ليس عندك مترجم للغة القياسية لأنى لاحظت عندما نسخت كودك لأنفذه وأعدله أنه به أكثر من تسع أخطاء فحاول تمشى مع الخطأ خطوة خطوة وتصححه

وتفضل:

#include <stdio.h>

void add_new_employee();
void disp_employee_info();
void disp_all_employees_info();


void main()
{
int request, loop;

/* display Menu options */
printf("Please select one of the following options:\n");
printf("1 - Add Information of a new employee\n");
printf("2 - Display an Employee Information\n");
printf("3 - Display all Employees Information\n");
printf("4 - Exit System\n");
scanf("%d", &request);

/* Processing user's request */
if (request ==1)
{
	 add_new_employee();
}

else if (request == 2)
{
	disp_employee_info();
}
else if (request == 3)
{
	disp_all_employees_info();
}
else if (request == 4)
{
   for(loop=0;loop==10050;loop++)
	 {
		clrscr();
		printf("\tsalam");
		exit(1);
	}
}
else
{
printf("Invalid Option ... try again");
}

}




void add_new_employee()
{

int EmplNo, total;
int EmplRank1,num, date;


char EmplName[30];
double Emp1Salary;
char MoreEmpl='y';
FILE *cfptr, *cfptr2, *cfptr3;


system("date>data.dat");

cfptr=fopen("Employees.dat","a");
printf("Enter Employee Number, Employee Name, Employee Salary, Employee Rank\n");
scanf("%d\n %s\n  %lf\n %d\n",&EmplNo,&EmplName,&Emp1Salary,&EmplRank1);
if(EmplRank1==1)
num = 5;
if(EmplRank1==2)
num = 4;
if(EmplRank1==3)
num = 3;
if(EmplRank1==4)
num = 2;

total = Emp1Salary * num / 100;


fprintf(cfptr,"Employee number:%d\n Employee name:%s\n Employee salary:%lf\n Employee rank:%d\n",EmplNo,EmplName,Emp1Salary,EmplRank1);
scanf("%s",&MoreEmpl);
if(MoreEmpl == 'y' || MoreEmpl == 'Y')
{
  add_new_employee();
}
fclose(cfptr);



total = Emp1Salary * num / 100;

cfptr2=fopen("employee2.dat", "a");
fprintf(cfptr2,"\nLoan Size: %f\n Loan Deduction: %d\n",Emp1Salary*3, total);
printf("add now...");
fclose(cfptr2);
if(MoreEmpl != 'y' || MoreEmpl != 'Y')
{
exit();
}

}




void disp_employee_info()
{
FILE *fptr, *fptr2, *fptr3;
int empno, loandeduction, loansize, reply, date;
char empname[30];
double empsalary;
int emprank, total, num;
int eno, ds_tk;


fptr=fopen("employees.dat","r");
rewind(fptr);
printf("Enter Employee Number to display employee information ");
scanf("%d\n",&eno);


fscanf(fptr,"Loan Size:%d\n Loan deduction:%d\n  Employee Number :%s\n Employee name: %lf\n  Employee salary:%d\n Loan rank:%d\n ",&loansize,&loandeduction,&empno,empname,&empsalary,&emprank);
if(emprank==1)
num = 5;
if(emprank==2)
num = 4;
if(emprank==3)
num = 3;
if(emprank==4)
num = 2;
total = empsalary * num / 100;
printf("Employee Number : %d\n", empno);
printf("Employee Name : %s\n", empname);
printf("Employee Salary: %lf\n",empsalary);
printf("Employee Rank : %d\n",emprank);
printf("Loan Size: %d\n", loansize);

fptr2=fopen("employee2.dat", "a");
fscanf(fptr2,"Employee Deduction:%d ", &loandeduction);
printf("Employee Deduction: %d", total);
fclose(fptr2);

system("type data.dat");

printf("\n\n\n\n\tReply on your Questions(press 1\n");
scanf("%d", &reply);
getchar();

if(reply == 1)
{
printf("\n\tDisplay Employees them not take tht Loan(press 2)");
scanf("%d", &ds_tk);
  if(ds_tk == 2)
  {
	disp_employee_info();
  }
}





fclose(fptr);
}




void disp_all_employees_info()
{
   system("type employee.dat");
}

وسلام

befor any great jop there is a bad jop had done

هذا الموضوع مغلق.

مواضيع مشابهة