السلام عليكم ورحمة الله وبركاته
اخواني الكرام لدي سؤال عن كتابة برنامج بسيط
وقمت بحله لكني اعتقد انه يجب ادخال دالة تكرار مثل while او for
السؤال هو كالتالي :
وحلي بعد السؤال
يا ريت اللي يقدر يساعد ما يبخل علي

وبارك الله فيكم سلف

في شركة للاتصالات تقرر اجراء استفتاء لزبائن الشركة. يطلب من كل زبون ان يجيب على 5 معايير (اسئلة) مختلفة "A-E" حيث ان لكل واحد منها وزن مختلف، كما هو مفصّل:
معايير من A-C : لها 15% من الوزن الكلي
معيار D: له 30% من الوزن الكلي.
معيار E: له 25% من الوزن الكلي.
لكل معيار (سؤال) يتم ادخال تقييم من 1-10.
يجب كتابة برنامج يستوعب تقييم الزبون بكل واحد من ال 5 معايير، ويقوم بحساب وطباعة التقييم النهائي الموزون.
ويقوم بطباعة رسالة التي تصف رضا الزبون حسب القائمة التالية:
مجال رضا الزبون العام --------------------------------- رسالة الطباعة
0-5 ---------------------------------------------------The customer is not satisfied
5-7 (لا يشمل 5) --------------------------------------The customer is slightly happy
7-8 (لا يشمل 7) --------------------------------------The customer is satisfied
8-10 (لا يشمل 8) ------------------------------------The customer is glad
مثال بعد تشغيل البرنامج:
Enter customer's satisfaction in category A: 3
Enter customer's satisfaction in category B: 8
Enter customer's satisfaction in category C: 5
Enter customer's satisfaction in category D: 7
Enter customer's satisfaction in category E: 4
Customer's Satisfaction in general is: 5.5
The customer is slightly happy
البرنامج الذي قمت بكتابته كالتالي:
#include <stdio.h>
void main()
{
float CatA, CatB, CatC, CatD, CatE, SatGen; //catA: customer's satisfaction in category A, CatB: customer's satisfaction in category B, CatC: customer's satisfaction in category C, CatD: customer's satisfaction in category D, CatE: customer's satisfaction in category E, SatGen:Customer's Satisfaction in general.
printf("Enter customer's satisfaction in category A\n");
scanf("%f", &CatA);
if (CatA>=1 && CatA<=10)
CatA;
else
printf("You have been entered a wrong number\n");
printf("Enter customer's satisfaction in category B\n");
scanf("%f", &CatB);
if (CatB>=1 && CatB<=10)
CatB;
else
printf("You have been entered a wrong number\n");
printf("Enter customer's satisfaction in category C\n");
scanf("%f", &CatC);
if (CatC>=1 && CatC<=10)
CatC;
else
printf("You have been entered a wrong number\n");
printf("Enter customer's satisfaction in category D\n");
scanf("%f", &CatD);
if (CatD>=1 && CatD<=10)
CatD;
else
printf("You have been entered a wrong number\n");
printf("Enter customer's satisfaction in category E\n");
scanf("%f", &CatE);
if (CatE>=1 && CatE<=10)
CatE;
else
printf("You have been entered a wrong number\n");
printf("Customer's Satisfaction in general is: %.1f\n", SatGen=(CatA+CatB+CatC)*15/100+CatD*30/100+CatE*25/100);
if (SatGen>=0 && SatGen<=5)
printf("The customer is not satisfied\n");
else
if (SatGen>5 && SatGen<=7)
printf("The customer is slightly happy\n");
else
if (SatGen>7 && SatGen<=8)
printf("The customer is satisfied\n");
else
if(SatGen>8 && SatGen<=10)
printf("The customer is glad\n");
else
printf("You have been entered an illegal values\n");
}