Skip to content

Instantly share code, notes, and snippets.

@bilalbayasut
Created March 29, 2019 13:04
Show Gist options
  • Save bilalbayasut/0a96180a672589d79f632d1649d5c791 to your computer and use it in GitHub Desktop.
Save bilalbayasut/0a96180a672589d79f632d1649d5c791 to your computer and use it in GitHub Desktop.
UWP DSA 2020 : struct
#include <iostream>
using namespace std;
struct Pc{
int ram;
int storage;
double battery;
string brand;
float processor;
string vga[2];
};
int main() {
Pc pcs_database[10] = {};
int menu;
Pc gaming;
do{
cout<<"selamat datang di aplikasi inventaris"<<endl;
cout<<"pilih menu anda"<<endl;
cout<<"1. tambah pc"<<endl;
cout<<"2. display1 pc"<<endl;
cout<<"3. quit"<<endl;
cin>>menu;
switch(menu) {
case 1 :
cout<<"tambah pc"<<endl;
cout<<"masukan data PC"<<endl;
cout<<"masukan ram :";
cin>>gaming.ram;
cout<<"masukan storage :";
cin>>gaming.storage;
cout<<"masukan battery :";
cin>>gaming.battery;
cout<<"masukan brand :";
cin>>gaming.brand;
cout<<"masukan processor :";
cin>>gaming.processor;
cout<<endl;
// insert into array
pcs_database[0] = gaming;
break;
case 2 :
cout<<"tampilkan list pc"<<endl;
cout<<"data yang anda masukan adalah:"<<endl;
cout<<"ram :"<<pcs_database[0].ram<<endl;
cout<<"storage :"<<pcs_database[0].storage<<endl;
cout<<"battery :"<<pcs_database[0].battery<<endl;
cout<<"brand :"<<pcs_database[0].brand<<endl;
cout<<"processor :"<<pcs_database[0].processor<<endl;
break;
case 3:
cout << "End of Program.\n";
break;
// you can have any number of case statements.
default : //Optional
cout << "Not a Valid Choice. \n"
<< "Choose again.\n";
break;
}
}while(menu != 3);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment