القائمة الرئيسية

الصفحات

 منصة تحفيظ القران الكريم اون لاين 

https://quranmo.com

برنامج MATLAB لحساب مساحة المستطيل و المربع والدائرة والمثلث باستخدام ادخال المستخدم USER_INPUT

fprintf('Select your choice and enter the option number!\n')
 fprintf('1) Area of Rectangle\n')
 fprintf('2) Area of square\n')
 fprintf('3) Area of circle\n')
 fprintf('4) Area of triangle\n')
 user_input = input('You Choice? : ');
 if user_input == 1 
 length = input('Enter the length of the rectangle: ');
 breadth = input('Enter the breadth of the rectangle: ');
 a = length*breadth;
 elseif user_input == 2
 side = input('Enter the length of the side of the square: ');
 a = side*side;
 elseif user_input == 3 
 radius = input('Enter the length of the radius of circle: ');
 a = pi*(radius^2);
 elseif user_input == 4
 height = input('Enter the height of the triangle: '); 
 base = input('Enter the base length of the triangle: ');
 a = 0.5*height*base; 
else fprintf('The input you have entered is wrong\n');
 fprintf('Please enter only numbers present in the choice');
 fprintf('Try Again!!!');
 end 
fprintf('Area = %.2f\n',a);

حيث ان
fprintf('Select your choice and enter the option number!\n')
 fprintf('1) Area of Rectangle\n')
 fprintf('2) Area of square\n')
 fprintf('3) Area of circle\n')
 fprintf('4) Area of triangle\n')
اكواد طباعة الخيارات ( 1- اختيار مساحة المستطيل - 2- اختيار مساحة المربع - 3- اختيار مساحة الدائرة 4- اختيار مساحة المثلث 

user_input = input('You Choice? : ');

كود تعريف اختيار المستخدم و INPUT كود الادخال 
 if user_input == 1 
 length = input('Enter the length of the rectangle: ');
 breadth = input('Enter the breadth of the rectangle: ');
 a = length*breadth;



 if user_input == 1 
اذا كان ادخال المستخدم = 1 " مساحة المستطيل
length = input('Enter the length of the rectangle: '); 
قم بادخال طول المستطيل 
breadth = input('Enter the breadth of the rectangle: ');
قم بادخال عرض المستطيل 

a = length*breadth;
حيث ان A مختصر كلمة المساحة AREA وتساوي المعرفات السابقة " الطول * العرض" 

وجميع المدخلات التالية بنفس الطريقة باختلاف القوانين 

وصولاً الى :
else fprintf('The input you have entered is wrong\n');
 fprintf('Please enter only numbers present in the choice');
 fprintf('Try Again!!!');
بمعنى اذا كان هناك اي مدخلات غير المدخلات المحددة يقوم البرنامج بطباعة جملة خطأ 

ختاما : 
 end 
fprintf('Area = %.2f\n',a);

كود الأغلاق وعرض النتيجة 


تقييم:

تعليقات