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

ابي اضيف شئ للكود

مغلق
بدأه طالب سي+ في 30 ديسمبر 2007 · 6 رد · 722 مشاهدة · في الأسئلة المجابة
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع
//**************************************
//	 

//**************************************
/* Super Calculator 2002 by Kyle to help me with else if and functions*/
#include <iostream.h> //needed for cout, cin, char (basic functions)
#include <conio.h> //for getch()
#include <clrscr.h> //needed to clear the screen

/*NOTE:::::: Do not enter a wrong value for 
number 1 or number 2 it will mess up the program
and force you to close it and reopen it again
I will be fixing this in a later version*/

float Add (float x,float y)
{
	return (x+y); //Returns the value X+Y
}

float Sub(float x,float y)
{
	return (x-y); //Returns the value X-Y
}

float Mul(float x,float y)
{
	return (x*y); // Returns the value X*Y
}

float Div(float x,float y)
{
	return (x/y); //Returns the value X/Y
}

int main() //The beggining of the program
{
	float num1, num2; //Declaring number1 and number 2
	char factor; //Declaring a char
	char yn; //Declaring Char Yes OR NO
	cout << "\t\t\tSuperCalc 2k2 made by Kyle C.\n\n\n"; //Prints SuperCalc 2k2 to the screen
	cout << "Enter two numbers: "; //I need to know how to make this exit if i want it to
	cin >> num1; //user enters 1 number && I need to know how to make it so that if a user types "D" or something he gets an error
	cin >> num2; //user enters another
	cout << "\n\nNumber one is, " << num1 << " and Number two is, " << num2 << "."; //Shows the user the number he has picked
	cout << "\n\nWhat do you want me to do? ( + , - , * , / ): "; //Asks the user what the prog should do
	cin >> factor; //Enter what the users wants to do
	cout << "You have chosen to " << factor << ".\n";
	if (factor == '+') //if the sign is + then do this
	{
		cout << num1 << factor << num2 << "=" << Add(num1, num2) << "\n";
	}
	else if (factor == '-') //if the sign is - then do this
	{
		cout << num1 << factor << num2 << "=" << Sub(num1, num2) << "\n";
	}
	else if (factor == '*')//if the sign is * then do this
	{
		cout << num1 << factor << num2 << "=" << Mul(num1, num2) << "\n";
	}
	else if (factor == '/')//if the sign is / then do this
	{
		cout << num1 << factor << num2 << "=" << Div(num1, num2) << "\n";
	}
	else if (factor != '-' && factor != '+' && factor != '/' && factor != '*') //if the sign is wrong then show a warning
	{
		cout << "Sorry I am confused with your input\n\n";
	}
	cout << "Do you want to continue? Y/N: "; //asks if the user wants to continue
	cin >> yn; //they enter a choice
	if (yn == 'n' || yn == 'N' ) //if char yn is n or N then exit the program
	{
		return 0;
	}
	else
		clrscr(); //If y is pressed then clear the screen and restart
		main(); //restart from main function
	return 0;
}

لوسمحت هذا عباره عن أله حاسبه اريد ان اضفيلها class

وشو الاشياء الي اضيفها+مأبغى اكتf.h.

الي جنب ايوستريم بس وشو الاشياء الي امسحها الي تبع .h.ابغي في برنامج class

الي يقدر يساعدني بس يقولي وشو احط فو كلاس انا اعملها

ويقولي int main

وش اضيفلها

#2

اخي الفاضل ..

بصراحة لم افهم ما تقصده

اقتباس
اريد ان اضفيلها class

هل تريد ان تجعل الحاسبه نفسها كلاس .. ؟؟ ام تضيف للبرنامج كلاس ؟؟؟

وضح المطلوب لكي نعرف نساعدك ..

تحياتي العطرة ..

يَارَبُ إِن ضَاقَت قُلُوُب الْنَّاسٍ عَنْ مّافِي .. مِنْ خَيْرٍٍ فَعَفْوكَ لَا يَضِيْقْ ..

#3

اضيف للبرنامج كلاس

#4

للرفع الي يعرف يساعدني مأبقى وقت

#5

اخي العزيز ..

والله عرفت انك تريد تضيف كلاس ..

ولكن ما هي فائدة الكلاس .. ؟؟

الكلاس ليس فقط كود يكتب ويضاف .. وانما جزء برمجي له فائدته ..

اكتب ما تريده من هذا الكلاس وها انا اكتب لك ذلك للمره الثانيه ..

تحياتي العطرة ..

يَارَبُ إِن ضَاقَت قُلُوُب الْنَّاسٍ عَنْ مّافِي .. مِنْ خَيْرٍٍ فَعَفْوكَ لَا يَضِيْقْ ..

#6

هذا مشروع انا اعرف اعمل class

بس مأعرف لهذا البرنامج شو يحتاج احط get_set

ايش احط بالضبط في كلاس ولا اي شئ ينحط؟؟؟؟

#7

السلام عليكم ,,

اقتباس
هذا مشروع انا اعرف اعمل class

بس مأعرف لهذا البرنامج شو يحتاج احط get_set

ايش احط بالضبط في كلاس ولا اي شئ ينحط؟؟؟؟

للأسف إذا كان صاحب المشروع لا يعرف فلا يوجد أحد يمكنه أن يعرف ما المطلوب, هذه المرة سيتم إغلاق الموضوع, أرجو في المرات القادمة أن تكون الأسئلة محددة حول نقطة معينة و مرفقة مع المعلومات المطلوبة ..

تحياتي ,,

تم تعديل هذه المشاركة بواسطة Khaled.Alshaya في 2 يناير 2008 في 02:22

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

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