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

[تنبيه - عنوان غير مناسب : ]مساعدة عاجلة =)

بدأه Ghadeer k في 11 يناير 2010 · 6 رد · 638 مشاهدة · في Microsoft Visual C#.NET
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

الــسلام علــيكم .. هذا السؤال اللي عندي :

1- Ask the user for his nae and his worked hour during the months.

2. Some user might wotk 1 month during a year while others might work 12 months.

3. Store all the workd hours per month for all the employees in a department

4. The department can have a maximum of 25 employees. Therefore after entering the first emplyee, ask the user if he has more employees to enter. If the number of employees reaches 25 then stop and print a report.

5. The year has 12 months.

6. Your program will calculate the average for Each employees.

7. Your program to print all the names and their average worked hours per month fr each employee.

نحسب المجموع حق كل موظف لحاله .. بغض النظر اتشغل شهر أو سنة كاملة

وبعدين نعرضهم بعد ما نحسب كل مجموع مع الأسماء

بدأت بإنشاء Class

private string employeeName;
        private int[] workHours = new int[12];



        public string getEmployeeName()
        {
            return employeeName;
        }

        public void setEmployeeName(string value)
        {
            employeeName = value;
        }

        public int getWorkHours()
        {
            return workHours;
        }


        public void setWorkHours(int value)
        {
            workHours = value;
        }

مع العلم اني مو متأكدة من طريقة الــ Array ..

 Employee[] employeeInfo = new Employee[25];

            for (int i = 0; i < employeeInfo.Length; i++)
            {
                employeeInfo = new Employee();
            }

            for (int i = 0; i < employeeInfo.Length; i++)
            {
                Console.Write("Please Enter Your Name: ");
                employeeInfo.setEmployeeName(Console.ReadLine());

            }

            Employee WorkHours = new Employee[12];

            for (int n = 0; n < workHours.Length; n++)
            {
                Console.Write("Please Enter Your Worked Hours: ");
                workHours[n] = Int32.Parse(Console.ReadLine());
            }

عندي أكثر من Error وأحتاج مساعدة في طريقة ربط البرنامج مع المجموع .. وشــكراً :)

#2

الأخ الكريم/الأخت الكريمة

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

مرحباً بكم في منتدى الفريق العربي للبرمجة

نود تنبيهك أن العنوان غير مناسب.

الرجاء اختيار عنوان مناسب أكثر في مواضيعك القادمة، وهذا بمثابة إشعار للأهمية.

وفي حال التكرار سيتعرض موضوعك للإغلاق والحذف!!!

قواعد المشاركة

/index.php?showtopic=29343

شاكرين لكم حُسن تعاونكم

مدونتي: C++ Tips and Tricks

#3

اليك محاولتي

#include "stdafx.h"
#include <string>
#include <iostream>
using namespace std;
#include<conio.h>
class Employee
{
private:
	string name;
	int workHours[12];
public:
	Employee()
	{
		//set all work hours to be zero
		for(int i=0;i<12;i++)workHours=0;
	}
	string getEmployeeName() 
    { 
        return name; 
    } 

    void setEmployeeName(string value) 
    { 
        name = value; 
    } 

    int getWorkHours(int month) 
    { 
		//month should be from 0 to 11
        return workHours[month]; 
    } 
    void setWorkHours(int month,int value) 
    { 
        workHours[month] = value; 
    }
	bool isThereWorkHour(int month)
	{
		if(workHours[month] == 0) return false;
		else return true;
	}
	int getTotalWorkHours(void)
	{
		int temp=0;
		for(int i=0;i<12;i++)
		{
			if(workHours > 0) temp+=workHours;
		}
		return temp;
	}
};

class Department
{
public:
	Employee e[25];
	Department()
	{
		for(int i=0;i<25;i++)
		{
			e.setEmployeeName("");
		}
	}
	void printReport(void)
	{
		int overallWorkHours=0;
		for(int i=0;i<25;i++)
		{
			if(e.getEmployeeName().length() > 0)
			{
				cout<<" Employee name " << e.getEmployeeName(); cout<<" Total Work Hours "<<e.getTotalWorkHours()<<"\n";
				overallWorkHours += e.getTotalWorkHours();
			}
		}
		cout<<" The overall work hours for the department "<<overallWorkHours<<"\n";
	}
};
int _tmain(int argc, _TCHAR* argv[])
{
	Department dAccounting;
	string empName;
	int w_hours;
	for(int i=0;i<25;i++)
	{
		cout<<"\t Welcome to our program\n";
		cout <<"Press any key to continue or Esc to exit\n";
		char ch=getch();
		if(ch == 27 )
		{
			dAccounting.printReport();
			break;
		}
		else
		{
			cout<<"Enter the employee name :\n";
			cin>>empName;
			dAccounting.e.setEmployeeName(empName);
			for(int j=0;j<12;j++)
			{
				cout <<"Enter the workHour for month "<<j+1<<" and then press Enter ";cin >> w_hours;
				dAccounting.e.setWorkHours(j,w_hours);
			}

		}
	}
	system("pause");
	return 0;
}
1
#4

هذا كود C++ :blink:

والكود في المشاركة الأولى اغلب الظن أنه C# :huh:

ممكن ترسوا على بر :lol:

تم تعديل هذه المشاركة بواسطة herch في 11 يناير 2010 في 20:38

#5
اقتباس

هذا كود C++

والكود في المشاركة الأولى اغلب الظن أنه C#

قمت بحل المسألة في الاعلى، ولم انظر الى المحاولة المرفقة، اعتقد ان محاولتي من الممكن ان تنفع في حال ان تساعدعلى فهم طريقة الحل وليس الحل نفسه

#6

الــ Codes بلغة الـ C#

أحتاج الى الحل بنفس اللغة .. بس شـــكراً في جميــع الأحوال :)

#7

..

تم تعديل هذه المشاركة بواسطة Ghadeer k في 19 يناير 2010 في 23:21

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

عدد الزوار حالياً

المتواجدون خلال آخر دقيقتين · يتحدّث كل ٣٠ ثانية

—الإجمالي—أعضاء مسجّلون—زوار بدون تسجيل

جارٍ التحقق من المتواجدين…