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

برنامج لحجز اماكن في طائره أرجو المساعده

مغلق
بدأه بـــدور في 21 أبريل 2004 · 5 رد · 574 مشاهدة · في ارشيف قسم C/C++
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السؤال:-

a small airline has just purchased a computer for its new automated reservations system, You have been asked to program the new system. You are to write a program to assign seats on each flight of the airline's only plane (capacity: 10seats).

Your program should display the following menu of alternatives___Please type 1 for "First Class" and Please type 2 for "Economy". If the person types 1 your program should assign a seat in the first class section (1-5). IF the person types 2, your program should assign a seat in the economy section (6-10). Your program should print a boarding pass indicating the person's seat number and wether it is in the first class or economy section of the plane.

Use asingle-subscripted array to represent the seating chart of the plane. Initialize all the elements of the array to 0 to indicate that all seats are empty. As each seat is assigned, set the corresponding elements of the array to 1 to indicate that the seat is no longer available.

Your program should never assign aseat that has already been assigned. When the first class section is full, your program should ask the person if it is acceptable to be placed in the economy section (and vice versa). If yes, then make the appropriate seat assignment. If no, then print the message "Next flight leaves in 3 hours."

my wrong answer is here and don't know how to complete plzzz help me

we have to use also file>>

وهاذي محاولتي

#include<iostream.h> 
#include<fstream>  error



int main()
{
char goTo;
int s[10]={0,0,0,0,0,0,0,0,0,0},n,j=1;




ofstream outf("seats.txt", ios::out); 

for (int i=0; i<10; i++) 
{
cout<<"Please type 1 for 'First class'\n"; 
cout<<"Please type 2 for 'Economy'\n";
cin>>n;
}

switch(n)
{
case 1:
outf << "(" << j << "-5)\n"; 
if(j>5);


}





return 0; 
}
#2

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

هذه محاولة اوليه لكتابه البرنامج..تقدرين تعدلين عليها اذا تبين ..لكن لاحظي انا كتبت البرنامج باستخدام c

..بس تحولينه الى

++c

#include<stdio.h> 


int main(){
	int i,daer;    
	int first,economy;     // عدادين لكل درجة عداد
	first=economy=0;     // تصفير العدادين

	for(i=0;;i++){   // بدون شرط توقف لاننا لا نعرف متى تمتلي الطائره
	printf("please type number \n");
	printf("1.top class \n");
	printf("2.Economy  \n");
	printf("3.exit from program \n");
	scanf("%d",&daer);

	if(daer==1){
  if(first>4) // اذا كان عدد المقاعد المحوزه مسبقا اكثر من 4 
  printf("\n\n\n ***sorry..top class is full*** \n\n\n");
  else{         //اذا كانوا اقل من 4
  	first++;   // نظيف لعداد الدرجه الاولى مقعد محجوز
  	printf("\n\n\n O.K ! \n\n\n"); 
  }
	}
	else if(daer==2){
  if(economy>4) //نفس الشي ولكن بالنسبه للدرجه الثانيه
  	printf("\n\n\n ***sorry..economy if full*** \n\n\n");
  else{
  	economy ++;
  	printf("\n\n\n  O.K !  \n\n\n");
  }
	}
	else
  return 0; 
	}
}

اقترح عليك اضافه شرط ..بحيث اذا كانت الدرجه الاولى والثانيه كلهم اكثر من 4

يطبع رساله الطائره ممتلئله ...

تم تعديل هذه المشاركة بواسطة warning في 22 أبريل 2004 في 06:25

#3

جزاك الله خير

بس البرنامج طالبين نستخدم array & files

واذا خلصت الseats في الeconomy او السكشن الثاني

البرنامج يسال اذا بروح بالسكشن الثاني ويحجزله واذا ما بغى تطلع العباره

Next flight leaves in 3 hours

#4

الملف الي بيفتحه البرنامج وش بسطه؟!

لاني مافهمت صراحه فيه اعداد ولا ايش؟

#5

الملف اللي بيفتحه بيكون فيه ارقام الـseats

المحجوزه يعني الــoutputs

#6

؟؟؟؟؟؟؟؟؟؟

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

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

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

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

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

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