#include<iostream.h>
#include<conio.h>
main() {
int i,pil,tothrg,byr,hrg,jml,kmb;
char menu;
cout<<"Warung Cak Kar\n";
cout<<"Menu Makanan Harga\n";
for (i=0; i<32; i++)
cout<<"-";
cout<<endl;
cout<<"1. Sate Kelinci Rp.15000\n";
cout<<"2. Ayam Kremes Rp.12000\n";
cout<<"3. Coto Makassar Rp.12000\n";
cout<<"4. Lontong Sayur Rp.13500\n";
cout<<"5. Rendang Daging Rp.18000\n";
cout<<"6. Es Teh Manis Rp.2500\n";
cout<<"7. Es Jeruk Rp.3500\n";
cout<<endl;
cout<<"Pilihan Anda adalah : ";
cin>>pil;
if (pil==1)
hrg=15000;
if (pil==2)
hrg=12000;
if (pil==3)
hrg=12000;
if (pil==4)
hrg=13500;
if (pil==5)
hrg=18000;
if (pil==6)
hrg=2500;
if (pil==7)
hrg=3500;
cout<<endl;
cout<<"Menu Pilihan\n";
for (i=0; i<22; i++)
cout<<"-";
cout<<endl;
cout<<endl;
if (pil==1)
cout<<"Sate Kelinci\n";
if (pil==2)
cout<<"Ayam Kremes\n";
if (pil==3)
cout<<"Coto Makassar\n";
if (pil==4)
cout<<"Lontong Sayur\n";
if (pil==5)
cout<<"Rendang Daging\n";
if (pil==6)
cout<<"Es Teh Manis\n";
if (pil==7)
cout<<"Es Jeruk\n";
cout<<endl;
cout<<"Jumlah yang Dipesan : ";
cin>>jml;
tothrg = jml * hrg;
cout<<"Harga Total : Rp. "<<tothrg<<endl;
cout<<"Dibayar : Rp. ";
cin>>byr;
kmb = byr - tothrg;
cout<<"Uang Kembalian : Rp. "<<kmb<<endl;
getch ();
}
Minggu, 22 Januari 2012
tugas Array
#include <cstdlib>
#include <iostream>
using namespace std;
main(){
char a[50];
int n;
int x;
cout<<"Jumlah Mahasiswa :" ;
cin>>x;
for(int i=1;i<=x;i++)
{
cout<<i <<"." <<"NIM :"; cin>>n;
cout<<" NAMA : " ; cin>>a ; cout<<endl;
}
system("PAUSE");
return EXIT_SUCCESS;
}
#include <iostream>
using namespace std;
main(){
char a[50];
int n;
int x;
cout<<"Jumlah Mahasiswa :" ;
cin>>x;
for(int i=1;i<=x;i++)
{
cout<<i <<"." <<"NIM :"; cin>>n;
cout<<" NAMA : " ; cin>>a ; cout<<endl;
}
system("PAUSE");
return EXIT_SUCCESS;
}
tugas fungsi String
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
cout<<"FUNGSI-FUNGSI DALAM STRING" <<endl;
cout<<endl;
cout<<"1. Inisialisasi string :" <<endl;
char kalimat[50]="Aku Sayang Kamu";
cout<<kalimat;
cout<<endl;
cout<<endl;
cout<<"2. Membaca string dari keyboard :"<<endl;
char nama[50];
cout<<"Nama :";
cin.getline(nama,sizeof(nama));
cout<<endl;
cout<<endl;
cout<<"3. Mengkopy string :" <<endl;
char kata1[30]="aku sayang kamu";
char kata2[40]="aku cinta kamu";
strcpy(kata1,kata2);
cout<<kata2;
cout<<endl;
cout<<endl;
cout<<"4. Fungsi strlen :"<<endl;
char kata[100]="Jangan tinggalkan aku";
int i=strlen(kata);
cout<<i;
cout<<endl;
cout<<endl;
cout<<"5. Fungsi strcat :"<<endl;
char cinta1[54]="Jangan Marah";
char cinta2[67]="Jangan sedih";
strcat(cinta1,cinta2);
cout<<cinta1;
cout<<endl;
cout<<endl;
cout<<"6. Fungsi strupr :" <<endl;
char string[90]="aku makan mangga";
strupr(string);
cout<<string;
cout<<endl;
cout<<endl;
cout<<"7. Fungsi strlwr :" <<endl;
char makan[40]="KUMERINDUKANMU";
strlwr(makan);
cout<<makan;
cout<<endl;
cout<<endl;
cout<<"8. Fungsi strstr :" <<endl;
char aku1[56]="Kamu dalam kenanganku";
char aku2[78]="Ku slalu mengharapkanmu";
strstr(aku1,aku2);
cout<<aku1;
cout<<endl;
cout<<endl;
cout<<"9. Fungsi strrev :" <<endl;
char kamu[78]="Cinta";
strrev(kamu);
cout<<kamu;
cout<<endl;
cout<<endl;
system("PAUSE");
return EXIT_SUCCESS;
}
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
cout<<"FUNGSI-FUNGSI DALAM STRING" <<endl;
cout<<endl;
cout<<"1. Inisialisasi string :" <<endl;
char kalimat[50]="Aku Sayang Kamu";
cout<<kalimat;
cout<<endl;
cout<<endl;
cout<<"2. Membaca string dari keyboard :"<<endl;
char nama[50];
cout<<"Nama :";
cin.getline(nama,sizeof(nama));
cout<<endl;
cout<<endl;
cout<<"3. Mengkopy string :" <<endl;
char kata1[30]="aku sayang kamu";
char kata2[40]="aku cinta kamu";
strcpy(kata1,kata2);
cout<<kata2;
cout<<endl;
cout<<endl;
cout<<"4. Fungsi strlen :"<<endl;
char kata[100]="Jangan tinggalkan aku";
int i=strlen(kata);
cout<<i;
cout<<endl;
cout<<endl;
cout<<"5. Fungsi strcat :"<<endl;
char cinta1[54]="Jangan Marah";
char cinta2[67]="Jangan sedih";
strcat(cinta1,cinta2);
cout<<cinta1;
cout<<endl;
cout<<endl;
cout<<"6. Fungsi strupr :" <<endl;
char string[90]="aku makan mangga";
strupr(string);
cout<<string;
cout<<endl;
cout<<endl;
cout<<"7. Fungsi strlwr :" <<endl;
char makan[40]="KUMERINDUKANMU";
strlwr(makan);
cout<<makan;
cout<<endl;
cout<<endl;
cout<<"8. Fungsi strstr :" <<endl;
char aku1[56]="Kamu dalam kenanganku";
char aku2[78]="Ku slalu mengharapkanmu";
strstr(aku1,aku2);
cout<<aku1;
cout<<endl;
cout<<endl;
cout<<"9. Fungsi strrev :" <<endl;
char kamu[78]="Cinta";
strrev(kamu);
cout<<kamu;
cout<<endl;
cout<<endl;
system("PAUSE");
return EXIT_SUCCESS;
}
Langganan:
Postingan (Atom)