O’ZBEKISTON RESPUBLIKASI AXBOROT TEXNOLOGIYALARI VA KOMMUNIKATSIYALARINI RIVOJLANTIRISH VAZIRLIGI MUHAMMAD AL-XORAZMIY NOMIDAGI TOSHKENT AXBOROT TEXNOLOGIYALARI UNIVERSITETI
MAVZU: Obyektga yo’naltirilgan dasturlash 4-Topshiriq
Guruh:222 : 21 Bajardi: Azimov Diyorbek
TOSHKENT 2021
1-Topshiriq
4.Universitet va kollej class larini yarating va ularni bog’lovchi funksiyalar yarating
#include
#include
using namespace std;
class Universitet {
private: int yoshi, soni;
public: string nomi, fakultetlari ;
bool binolari, yotoqxona ;
void set_soni(int x) {
soni = x;
}
int get_soni() {
return soni;
}
};
class kollej{
private: int soni;
public: string nomi,hududi;
bool binolari ,yotoqxona;
void set_soni(int x) {
soni = x;
}
int get_soni() {
return soni;
}
};
Universitet a[1000];
kollej b[1000];
int n = 5, m = 5;
void insert_somedata();
void insert_somedata_tel();
void Clear();
void find_student(int study) {
int z = 0;
for (int i = 0; i < n; i++) {
if (study >= a[i].get_soni()) {
z += 1;
cout << "\n---------------------\n";
cout << z << "-muassasa ( U N I V E R S I T E T )";
cout << "\n---------------------\n";
cout << "Universitet nomi: " << a[i].nomi << endl;
cout << "Talabalr soni: " << a[i].get_soni() << endl;
}
}
for (int i = 0; i < m; i++) {
if (study >= b[i].get_soni()) {
z += 1;
cout << "\n---------------------\n";
cout << z << "-muassasa ( K O L L E J )";
cout << "\n---------------------\n";
cout << "Nomi: " << b[i].nomi << endl;
cout << "Talabalr soni: " << b[i].get_soni() << endl;
}
}
if (z == 0) cout << "Afsuski bunday oliygoh yo'q'...";
}
int main() {
int type_insert, study;
cout << "Malumotlarni o'zingiz kiritasizmi yoki kiritilganlardan foydalanasizmi'? (1-o'zim kiritaman; 2-kiritilgan ma'lumotlardan foydalanish. 2 ni bosish tavsiya etiladi...): "; cin >> type_insert;
if (type_insert == 1) {
cout << "Nechta ma'lumot topmoqchisiz': "; cin >> n;
for (int i = 0; i < n; i++) {
int c;
cout << i + 1 << "-Universitet nomi: "; cin >> a[i].nomi;
cout << i + 1 << "- Talabalar soni: "; cin >> c; a[i].set_soni(c);
Clear();
}
cout << "Nechta telefon kiritmoqchisiz: "; cin >> m;
for (int i = 0; i < m; i++) {
int c;
cout << i + 1 << "-kollej nomi: "; cin >> b[i].nomi;
cout << i + 1 << "- Talabalr soni: "; cin >> c; a[i].set_soni(c);
Clear();
}
}
else {
insert_somedata();
insert_somedata_tel();
}
Clear();
cout << "Taxminingizni kiriting men sizga aytib beraman: "; cin >> study;
find_student(study);
system("pause>nul");
return 0;
}
void insert_somedata() {
string nomi[1000] = { "Pedagokika universiteti", "Jahon tillari", "TATU", "Nam DU", "Far Du" };
int soni[1000] = { 10000,250000,63400,96000,54950 };
for (int i = 0; i < 5; i++) {
a[i].nomi = nomi[i];
a[i].set_soni(soni[i]);
}
}
void insert_somedata_tel() {
string nomi[1000] = { "Ibn Sino","Al Farg'oniy'","Do'stlik'", "Xorazmiy ", "San'at" };
int soni[1000] = { 15230,117600,18900,78750,10870 };
for (int i = 0; i < 5; i++) {
b[i].nomi = nomi[i];
b[i].set_soni(soni[i]);
}
}
void Clear()
{
#if defined_WIN32
system("cls");
#elif defined(Linux)
system("clear");
#elif defined(Apple)
system ("clear");
#endif
}
2-Topshiriq
Tovar sinfini yarating. Unda kamida 5 ta maydon va ularni ekranga chiqaruvchi, qayta ishlovchi usullarni yarating.
#include
using namespace std;
class Tovar
{
public:
string nomi;
string rusumi;
string xotirasi;
int narxi;
string rangi;
public:
void Smartphone (int a){
if(a==11)
cout<<"Android so'ngi versiya':"<
else
cout<<"Android oldingi versiya:"< }
void Turi (float b)
{
if(b>=2000000)
cout<<"REDMI android 10:"<
else
cout<<"REDMI android 9:";
cin>>b;
}
Tovar()
{
cout<<"Yaratildi !!!"<
}
~Tovar()
{
cout<<"O'chirildi!!!"<
}
};
int main()
{int x,y;
cout<< " xga Android versiyasini kiriting:";
cin>>x;
Tovar ob1;
ob1.nomi="Telefon";
ob1.rusumi="Redmi 9T";
ob1.xotirasi="128 Gb";
ob1.narxi=2000000;
ob1.rangi="Avrora";
cout<<"Telefon nomi: "<
cout<<"Telefon rusumi : "<
cout<<"Telefon narxi somda :"<
cout<<"Telefon rangi : "<
cout<<"Telefon xotirasi : "<
ob1.Smartphone(x);
cout<<"Android versiya:";
cin>>y;
ob1.Turi(y);
return 0;
}
3-Topshiriq
Geometric_shakl sinfi yaratilsin va konstruktor e’lon qilinsin . Unda kamida uchta maydon va ularni ekranga chiqaruvchi va qayta ishlovchi sinf metodlarini yarating.
#include
using namespace std;
class Geometrik_shakl
{
public:
string nomi;
string turi;
int burchaklari ;
int tomonlari ;
public:
void Turi (int a){
if(a==4)
cout<<"Bu shakl to'rtburchak:"<
else
cout<<"Bu uchburchak:"<
}
void Burchaklari(float b)
{
if(b>=180)
cout<<"Parallelogram:"<
else
cout<<"Kvadrat:";
cin>>b;
}
Geometrik_shakl()
{
cout<<"Yaratildi !!!"<
}
~Geometrik_shakl()
{
cout<<"O'chirildi!!!"<
}
};
int main()
{int x,y;
cout<< " xga Tomonlari sonini kiriting:";
cin>>x;
Geometrik_shakl ob1;
ob1.nomi="Parallelogram";
ob1.turi="To'rtburchak'";
ob1.burchaklari =4;
ob1.tomonlari =4;
cout<<"Geometrik shakl nomi: "<
cout<<"Geometrik shakl turi : "<
cout<<" Geometrik shakl burchaklari soni:"<
cout<<"Geometrik shakl tomonlari soni : "<
ob1.Turi(x);
cout<<"Geometrik shakl nomi:";
cin>>y;
ob1.Burchaklari (y);
return 0;
}
4-Topshiriq
Firmaning xodimi xaqida quyidagi ma’lumotlar mavjud: familiyasi, ismi, yoshi, xarbiy xizmatga layoqatligi. Shu ma’lumotlarga asoslanib, xarbiy xizmatga layoqatli eng yosh xodimning familiyasini aniqlash dasturini tuzing.
#include
#include
#include
using namespace std;
class Xodim
{
public:
string familyasi,ismi;
string sharifi;
string viloyati ;
string tumani ;
string sogligi;
int yoshi ;
int boyi ;
string xizmatga_layoqatliligi;
void Balandligi(float a){
if(a>167)
cout<<"Harxiy xizmatga layoqatli:"<
else
cout<<"Boyi togri kelmaydi:"<}
};
int main ()
{int x,y;
cout<< " xga xodimning boyini kiriting:";
cin>>x;
Xodim ob1,ob2;
ob1.ismi="Mohidil";
ob1.familyasi="Akbarova";
ob1.sharifi="Abdurashidovna";
ob1.viloyati="Namangan";
ob1.tumani="Namangan";
ob1.sogligi="Soglom";
ob1.yoshi=18;
ob1.boyi=175;
ob1.xizmatga_layoqatliligi="layoqatli";
cout<<"Xodimning familyasi: "<
cout<<"Xodimning ismi :"<
cout<<"Xodimning sharifi: "<
cout<<"Xodimning viloyati :"<
cout<<"Xodimning tumani :"<
cout<<"Xodimning sogligi :"<
cout<
cout<<"Xodimning boyi :"<
ob1.Balandligi(x);
return 0;
}
e’tiboringiz uchun
rahmat
Do'stlaringiz bilan baham: |