14 MAYIS 2017
PAZAR
15.50
C++
Youtube
Youtube kanalım açıldı! Daha detaylı ve güncel konu anlatımları için takip etmeyi unutmayın.
C++ Uçak Rezervasyon Sistemi Örneği

Bilet alma işlemleri için gerçekleştirilen bir çalışma olacaktır.

 

Kullanıcılara ekonomi ve birinci sınıf seçenekleri sunulacaktır. Birinci Sınıf 1-5 arası koltuklar, ekonomi ise 6-10 arası koltukları temsil eder. Bunun için tek boyutlu bir dizi kullanın. Kullanıcıdan gelen verilere göre koltuklara yerleştirin. Boşta koltuk kalmadığında uyarı verdirin.

ÇÖZÜM

#include <iostream>
#include <windows.h> // Renklendirme
#include <iomanip>
using namespace std;

int main() {
	HANDLE  hConsole; // Renklendirme
	hConsole = GetStdHandle(STD_OUTPUT_HANDLE); // Renklendirme
	
	int son=1, secim, sayac=0, sayac2=0, k; // k: Renklendirme
	bool koltuklar[11] = {false};
	
	while(son != -1) {
    	SetConsoleTextAttribute(hConsole, 240); // Renklendirme
		cout << "Birinci Sinif icin 1'e, Ekonomi icin 2'ye basin:";
    	SetConsoleTextAttribute(hConsole, 7);
    	cout << "   ";
			cin >> secim;
		if(secim == 1) {
			for(int j=1; j<6; j++) {
				if(koltuklar[j] == false) {
					koltuklar[j] = true;
					++sayac;
    				SetConsoleTextAttribute(hConsole, 10);
					cout << "\n----> Birinci Sinif " << j << " nolu koltuk satin alindi.\n\n";
    				SetConsoleTextAttribute(hConsole, 7);
					break;
				}
				if(sayac == 5) {
    				SetConsoleTextAttribute(hConsole, 12);
					cout << "\n\t!Birinci Sinifta koltuk kalmamistir.\n\n";
    				SetConsoleTextAttribute(hConsole, 7);
					break;
				}
			}
		} else if(secim == 2) {
			for(int j=6; j<11; j++) {
				if(koltuklar[j] == false) {
					koltuklar[j] = true;
					++sayac2;
    				SetConsoleTextAttribute(hConsole, 11);
					cout << "\n----> Ekonomi " << j << " nolu koltuk satin alindi.\n\n";
    				SetConsoleTextAttribute(hConsole, 7);
					break;
				}
				if(sayac2 == 5) {
    				SetConsoleTextAttribute(hConsole, 12);
					cout << "\n\t!Ekonomide koltuk kalmamistir.\n\n";
    				SetConsoleTextAttribute(hConsole, 7);
					break;
				}
			}
		}
	}
}

ÇIKTI

YORUMLAR 0
Bu konuya henüz kimse yorum yapmadı.
İlk yorumu sen yapmak ister misin?
YORUM BIRAK
Şuanda bu yoruma cevap yazıyorsunuz:
İptal Et