Ticker

6/recent/ticker-posts

Program Dalam Bahasa C++

#include <iostream>
#include <string.h>

using namespace std;
void awal(){
          cout<<"____________________________________________________________"<<endl;}
int main()
{int pilih,usia,tahun,lahir;
char nd[20];
char nb[10];
char ttl[30];
char password [20];
char username [20];
char y,status[10];
char ulang;
tahun=2013;
pilih=1;
          awal();
          cout<<"\t\tprogram by Tofa Riyadi"<<endl;
          awal();cout<<endl;
          cout<<"\t\tmahasiswa UAD 2012/2013"<<endl<<endl;
          awal();
          cout<<"masukkan nama depan anda\t\t:";cin.getline(nd,sizeof(nd));
          cout<<"masukkan nama belakang anda\t\t:";cin.getline(nb,sizeof(nb));
          cout<<endl;
          cout<<"masukkan tempat/tanggal lahir anda\t:";cin.getline(ttl,sizeof(ttl));
          cout<<endl;
          cout<<"status anda saat ini apakah sedang pacaran/jomblo:";
          cin.getline(status,sizeof(status));
          cout<<"masukkan tahun anda lahir:";cin>>lahir;
          usia=tahun-lahir;
         
          cout<<endl;
          cout<<"untuk username silahkan anda ketikkan nama depan anda"<<endl;
          cout<<"untuk password ketikkan status anda. pacaran/jomblo"<<endl;
          do{awal();
          cout<<"\t\t\tLOGIN"<<endl;
          cout<<"username\t";cin>>username;
          cout<<"password\t";cin>>password;
cout<<endl<<endl;
          if((strcmp(username,nd)==0)&&(strcmp(password,status)==0))
do{
{cout<<"selamat "<<nd<<" "<<nb<<", anda berhasil masuk menuju"<
cout<<"\n\t\tprogram selanjutnya";
cout<<endl<<endl;
cout<<"nama lengkap anda : "<<nd<<" "<<nb<<endl;
cout<<"TTL anda          : "<<ttl<<endl;
cout<<"usia anda saat ini: "<<usia<<" tahun"<<endl<<endl;
cout<<"status "<<nd<<" "<<nb<<" saat ini sedang "<<status<<endl;
if((strcmp(status,"pacaran")==0))
cout<<"selamat yah,,,\nmoga langgeng sama si do'i."<<endl;
else{
          cout<<"ha....\nketahuan deh lagi jomblo,, :P"<<endl;
cout<<"yang sabar yah,\njodoh itu g' kemana ko'."<<endl;
cout<<"lau kamu mau, pacaran sama aku ja...\nhe,\nkidding coy..."<<endl;}
          awal();cout<<endl<<endl;
          cout<<"tekan 1 untuk melihat program luas segitiga"<<endl;
          cout<<"tekan 2 untuk melihat program calculator"<<endl;
          cout<<"tekan 3 untuk melihat program melihat nilai"<<endl;
          int tofa;
          cout<<"masukkan pilihan:";cin>>tofa;
          switch(tofa)
          {
          case 1:
          cout<<"program penghitung luas segitiga"<<endl<<endl;
int luas,alas,tinggi;
cout<<"masukkan alas:";cin>>alas;
cout<<"masukkan tinggi:";cin>>tinggi;
luas=alas*tinggi/2;
cout<<"luas segitiga adalah:"<<luas<<endl<<endl;
break;
case 2:
          int a,b,c,pil;
          char r;
                   cout<<"calculator sederhana"<
                   cout<<endl;
                   cout<<"masukkan angka pertama:";cin>>a;
                   cout<<"masukkan angka kedua:";cin>>b;
                   cout<
                   cout<<"perintah yang akan dijalankan"<<
                   cout<<"1.tambah(+)"<<endl;
                   cout<<"2.kurang(-)"<<endl;
                   cout<<"3.bagi(:)"<<endl;
                   cout<<"4.kali(*)"<<endl;
                   cin>>pil;
                   cout<<endl;
                   {        if(pil==1)
                             {        c=a+b;
                                      cout<<a<<endl;
                                      cout<<b;
                                      cout<<"_____+"<<endl;
                                      cout<<c;}
                                      else
                                      if(pil==2)
                                      {        c=a-b;
                                                cout<<a<<endl;
                                                cout<<b;
                                                cout<<"____-"<<endl;
                                                cout<<c;}
                                                else
                                                if(pil==3)
                                                {        c=a/b;
                                                          cout<<a<<endl;
                                                          cout<<b;
                                                          cout<<"____:"<<endl;
                                                          cout<<c;}
                                                          else
                                                          if(pil==4)
                                                          {        c=a*b;
                                                                   cout<<a<<endl;
                                                                   cout<<b<<endl;
                                                                   cout<<"____*"<<endl;
                                                                   cout<<c;
                                                                   }}
                             cout<<endl;
                             break;
                             case 3:
                                      float uts, uas,nilai;
cout<<"====Program Kelululsan====\n";
awal();
cout<<" Nilai UTS : ";cin>>uts;
cout<<" Nilai UAS : ";cin>>uas;
nilai = (0.7 * uts) + (0.3*uas);
cout<<" Nilai Akhir Anda : "<<nilai<<endl;
if (nilai >= 60)
{awal();
cout<<" Selamat Anda Lulus \n";}
else {
cout<<" maav, Anda Gagal\n";}
if (nilai<=50)
{cout<<"Grade E\n";cout<<"Mengulang";}
else if (nilai<=60)
{cout<<"Grade D\n";cout<<"Kurang";}
else if (nilai<=75)
{cout<<"Grade C\n";cout<<"Cukup";}
else if (nilai<=85)
{cout<<"Grade B\n";cout<<"Baik";}
else if (nilai<=100)
{cout<<"Grade A\n";cout<<"Excellent";}
cout<<endl<<endl;
break;
                             default:
                             cout<<"no yang anda tuju sedang sibuk"<<endl;
                             break;}
cout<<"untuk mengulang program ini tekan (k)"<
cout<<" jika tidak masukkan sembarang:";cin>>y;}
cout<<endl<<endl;
}while(y=='k');
else if((username!=nd)&&(strcmp(password,nb)==0))
cout<<"maaf, username yang anda masukkan salah."<<endl;
else if((strcmp(username,nd)==0)&&(password!=nb))
cout<<"maaf, password yang anda masukkan salah."<<endl;
else
cout<<"maav, password dan username anda salah. silahkan coba lagi"<<endl;
          {
awal();
cout<<"untuk username silahkan anda ketikkan nama depan anda"<<endl;
          cout<<"untuk password silahkan anda ketikkan nama belakang anda"<<endl;}
awal();
cout<<"untuk mengulang program keseluruhan tekan y:";cin>>ulang;
}while(ulang=='y');
return 0;
}

Posting Komentar

0 Komentar