• 0
  • مالي خلق
  • أتهاوش
  • متضايق
  • مريض
  • مستانس
  • مستغرب
  • مشتط
  • أسولف
  • مغرم
  • معصب
  • منحرج
  • آكل
  • ابكي
  • ارقص
  • اصلي
  • استهبل
  • اضحك
  • اضحك  2
  • تعجبني
  • بضبطلك
  • رايق
  • زعلان
  • عبقري
  • نايم
  • طبيعي
  • كشخة
  • النتائج 1 إلى 5 من 5

    الموضوع: Whats wrong ?!

    1. #1
      التسجيل
      21-02-2002
      الدولة
      Blue
      المشاركات
      728
      المواضيع
      81
      شكر / اعجاب مشاركة

      Question Whats wrong ?!

      #include <stdio.h>
      int main()
      {
      int grade;
      int aCount = 0 , bCount = 0, cCount = 0, dCount = 0, fCount = 0;

      printf("Enter a letter for the grades :\n");
      printf("Enter EOF To end the opration\n");

      while ( ( grade = getchar() ) != EOF )
      {
      switch ( grade )
      {
      case 'A': case 'a':
      ++aCount;
      break;
      case 'B': case 'b' :
      ++bCount;
      break;
      case 'C' : case 'c':
      ++cCount;
      break;
      case 'D' : case 'd' :
      ++dCount;
      break;
      case 'F' : case 'f' :
      ++fCount;

      break;
      default:

      printf("Incorrect letter grade entered\n");
      printf("Enter a new grade \n");
      break;
      }
      }

      printf( "\nTotals for each letter grade are:\n" );
      printf("A: %d\n",aCount);
      printf("B: %d\n",bCount);
      printf("C: %d\n",cCount);
      printf("D: %d\n",dCount);
      printf("F: %d\n",fCount);
      return 0;
      }

      Whats Wrong Now Guys



      So maybe tomorrow
      I'll find my way home
      So maybe tomorrow
      I'll find my way home

      I look around at a beautiful life
      Been the upperside of down
      Been the inside of out
      But we breathe
      We breathe

      I wanna breeze and an open mind
      I wanna swim in the ocean
      Wanna take my time for me
      All me


    2. #2
      التسجيل
      09-12-2000
      الدولة
      امريكا / كانساس /لورانس
      المشاركات
      2,961
      المواضيع
      93
      شكر / اعجاب مشاركة

      Re: Whats wrong ?!

      انت معرف grade على انه int.. و بعدين تستخدمه على انه char... ما يصلح

      انا ما ادري عن فنكشن getgrade وش ترجع... لكن اذا كانت ترجع حرف فالمفروض تعرف grade باستخدام char

      و نقطه ثانيه هي كلمة EOF... لو بتستخدم char... المتغير ما يقدر يشيل اكثر من حرف على حسب علمي... لازم تستخدم string عشان تقدر تشيل كلمة. فالأفضل لك انك تبدل كلمة EOF ب X او شي من هالقبيل... اهم شي يكون حرف واحد.

      hope that helps!
      سبحان الله و بحمده... سبحان الله العظيم



    3. #3
      التسجيل
      21-02-2002
      الدولة
      Blue
      المشاركات
      728
      المواضيع
      81
      شكر / اعجاب مشاركة

      Wink Re: Whats wrong ?!

      اقتباس المشاركة الأصلية كتبت بواسطة Arsene Lupin
      انت معرف grade على انه int.. و بعدين تستخدمه على انه char... ما يصلح

      انا ما ادري عن فنكشن getgrade وش ترجع... لكن اذا كانت ترجع حرف فالمفروض تعرف grade باستخدام char

      و نقطه ثانيه هي كلمة EOF... لو بتستخدم char... المتغير ما يقدر يشيل اكثر من حرف على حسب علمي... لازم تستخدم string عشان تقدر تشيل كلمة. فالأفضل لك انك تبدل كلمة EOF ب X او شي من هالقبيل... اهم شي يكون حرف واحد.

      hope that helps!
      it worked thx ^^
      but what about this one

      #include <stdio.h>

      #define TAX 0.0825


      int main()
      {
      int meal_price, sales_tax, amt_tendered, change, grand_total, total;
      int num_customers, response;

      grand_total = 0.0;
      num_customers = 0;

      printf("\n\n*** C-Side Restaurant***\n\n");
      printf("\n\nDo you want to process a customer ?");
      printf("\n\nEnter 1 for yes 0 for no : \n");
      scanf("%d",&response);

      while ( response == 1 )

      {
      printf("\n\nEnter the price of the meal : $");
      scanf("%1f",&meal_price);
      printf("\n\n");

      sales_tax = meal_price * TAX;
      total = meal_price + sales_tax;

      printf("\nPrice of meal : %6.2f",meal_price);
      printf("\nSales Tax : %6.2f",sales_tax);
      printf("\n-------------------\n");
      printf("\nThe Total Amount: %6.2f\n\n",total);

      printf("\nEnter Amount Tendered : $");
      scanf("%1f",&amt_tendered);
      printf("\n\n");

      change = amt_tendered - total;

      printf("\n Amount Tendered : $ %6.2f",amt_tendered);
      printf("\n Total Amount : $ %6.2f ",total);
      printf("\n-------------------");
      printf("Change : $ %6.2f",change);


      ++num_customers;
      grand_total += total;


      printf("\n\nDo you want to process a customer ?");
      printf("\n\nEnter 1 for yes 0 for no");
      scanf("%d",&response);

      }

      printf("\n\nGrand Totals : ");
      printf("\n\n Total Customers : %d",num_customers);
      printf("\n\n Total Receipts : %.2f\n\n",grand_total);

      return 0;
      }





      So maybe tomorrow
      I'll find my way home
      So maybe tomorrow
      I'll find my way home

      I look around at a beautiful life
      Been the upperside of down
      Been the inside of out
      But we breathe
      We breathe

      I wanna breeze and an open mind
      I wanna swim in the ocean
      Wanna take my time for me
      All me


    4. #4
      التسجيل
      09-12-2000
      الدولة
      امريكا / كانساس /لورانس
      المشاركات
      2,961
      المواضيع
      93
      شكر / اعجاب مشاركة

      Re: Whats wrong ?!

      صراحه انا متعلم على ال C++... يعني ما اعرف بالظبط اسلوب استخدام printf و scanf


      لكن نفرض انه سليم... ايش بالظبط المشلكه في البرنامج؟... هل المشكله في ان البرنامج ما يسوي الي مطلوب منه؟ او البرنامج من اصله فيه اخطاء عند ال compile؟

      عموما جرب تعدل في تعريف التاكس عندك اذا ما كنت متأكد من طريقتك.

      استخدم:

      ;int const TAX = 0.0825

      او عرفها عادي جوا ال main و متى ما زبط البرنامج جرب تحطها برا.


      نصيحه : حاول تستخدم علامات الكومينتس عشان تشرح البرنامج الي تشتغل عليه... لأنه ممكن ترجع بعد فتره تكون ناسي وش المفروض يسوي البرنامج في مكان معين. و راح تفيدك جدا اذا خليتها عاده في كتابة برامج طويله.
      سبحان الله و بحمده... سبحان الله العظيم



    5. #5
      التسجيل
      07-09-2003
      المشاركات
      9
      المواضيع
      0
      شكر / اعجاب مشاركة

      Cool Re: Whats wrong ?!

      السلام عليكم ..

      اخ black wolf .. اطلعت على كود البرنامج تبعك ووضبطته لك وبأعلمك الاخطاء الي طحت فيها ..

      اولا .. انت عرفت المتغيرات ( meal_price, sales_tax, amt_tendered, change, grand_total, total ) من نوع "int" وانت جالس تتعامل معها كــ " float "

      ثانيا .. اذا قراءت قراءة متغير من نوع " float " يجب ان تستعمل ( f% ) دون وضع اي رقم مثل ما فعلت انت scanf("%1f",&meal_price);

      وضع الارقام بعد علامة الـ ( % ) يكون في الـ printf فقط ..


      وهذا الملف الذي عدلت فيه سأقوم بأرفاقه ..
      وأرجو اكون افدتك

      -----------------------------------------------------------

      /* ---------------- ( SNIPER ) -------------------*/


      #include <stdio.h>

      #define TAX 0.0825


      int main()
      {
      float sales_tax, amt_tendered,meal_price, change, grand_total, total;
      int num_customers, response;


      grand_total = 0.0;
      num_customers = 0;

      printf("\n\n*** C-Side Restaurant***\n\n");
      printf("\n\nDo you want to process a customer ?");
      printf("\n\nEnter 1 for yes 0 for no : \n");
      scanf("%d",&response);

      while ( response == 1 )

      {
      printf("\n\nEnter the price of the meal : $");
      scanf("%f",&meal_price);
      printf("\n\n");

      sales_tax = meal_price * TAX;
      total = meal_price + sales_tax;

      printf("\nPrice of meal : %6.2f",meal_price);
      printf("\nSales Tax : %6.2f",sales_tax);
      printf("\n-------------------\n");
      printf("\nThe Total Amount: %6.2f\n\n",total);

      printf("\nEnter Amount Tendered : $");
      scanf("%f",&amt_tendered);
      printf("\n\n");

      change = amt_tendered - total;

      printf("\n Amount Tendered : $ %6.2f",amt_tendered);
      printf("\n Total Amount : $ %6.2f ",total);
      printf("\n-------------------");
      printf("Change : $ %6.2f",change);


      ++num_customers;
      grand_total += total;


      printf("\n\nDo you want to process a customer ?");
      printf("\n\nEnter 1 for yes 0 for no");
      scanf("%d",&response);

      }

      printf("\n\nGrand Totals : ");
      printf("\n\n Total Customers : %d",num_customers);
      printf("\n\n Total Receipts : %.2f\n\n",grand_total);

      return 0;
      }


      /* ---------------- ( SNIPER ) -------------------*/

    المواضيع المتشابهه

    1. whats wrong now ?!
      بواسطة : Darkseeker , في مقالات البرمجة
      مشاركات: 2
      آخر مشاركة: 09-03-2004, 05:04 PM
    2. المساعدة أخوان
      بواسطة : Neo_Ark , في منتديات اسلامية
      مشاركات: 0
      آخر مشاركة: 22-12-2003, 12:24 PM
    3. مشاركات: 22
      آخر مشاركة: 17-10-2003, 01:21 PM
    4. TGS 2003 : فاينل فانتسي 7 : أدفينت شيلدرن ... و نظره من المعرض
      بواسطة : تايدوس إمبرطور ال RPG , في منتدى فاينال فانتاسي
      مشاركات: 33
      آخر مشاركة: 30-09-2003, 02:11 PM

    ضوابط المشاركة

    • لا تستطيع إضافة مواضيع جديدة
    • لا تستطيع الرد على المواضيع
    • لا تستطيع إرفاق ملفات
    • لا تستطيع تعديل مشاركاتك
    •