Rabu, 15 Januari 2014
Selasa, 14 Januari 2014
Senin, 13 Januari 2014
goto XY menggunakan C++
#include <stdio.h> // file header menginput gets
#include <conio.h>
#include <iostream.h>
//file header tanpa #include <iomanip.h>
garis() // -> fungsi sederhana
{
cout<<"-----------------------------------------------\n";
}
kolom()
{
cout<<"===============================================\n";
cout<<"\tDATA NILAI MAHASISWA 2013\n";
cout<<"===============================================\n";
cout<<"No. Nim Nama Nilai Ket\n";
cout<<"===============================================\n";
}
char *ket(float nilai)
{
if(nilai>=70)
return "Lulus"; //fungsi return
else
return "Gagal";
}
main()
{
int i,y,jumlah;
char input;
struct // -> posisi structure
{ // struct
char nim[15],nama[15],*ket[15]; // {
float nilai; // elemen_structure;
}mahasiswa[5]; // }nama_tipe_struktur[array];
clrscr();
program:
cout<<"Masukkan Nilai data mahasiswa : ";cin>>jumlah;
cout<<endl;
for(i=1;i<=jumlah;i++){
cout<<"Data Ke - "<<i<<endl; // -> structure mahasiswa
cout<<"masukkan NIM : ";cin>>mahasiswa[i].nim;
cout<<"masukkan Nama : ";gets(mahasiswa[i].nama);
cout<<"masukkan Nilai : ";cin>>mahasiswa[i].nilai;
cout<<endl;
y=18; // -> ini dalam menentukan kolom, di dalam penempatan input
}
kolom();
for(i=1;i<=jumlah;i++){
gotoxy(1,y);cout<<i; //tanpa <iomanip.h>
gotoxy(9,y);cout<<mahasiswa[i].nim; //menggunakan gotoxy(x,y);cout<<...;
gotoxy(17,y);cout<<mahasiswa[i].nama;
gotoxy(25,y);cout<<mahasiswa[i].nilai;
gotoxy(33,y);cout<<ket(mahasiswa[i].nilai); //pemanggilannya seperti ini.
y++; // -> ini syarat agar tampilan terjadi perulangan
cout<<endl;
}
garis();
cout<<"Mau Input Data Lagi [Y/T]? ";cin>>input;
if(input=='Y'||input=='y')
goto program;
else
cout<<"\nTERIMA KASIH ANDA TELAH BELAJAR BORLAND C++\n";
getch();
}
#include <conio.h>
#include <iostream.h>
//file header tanpa #include <iomanip.h>
garis() // -> fungsi sederhana
{
cout<<"-----------------------------------------------\n";
}
kolom()
{
cout<<"===============================================\n";
cout<<"\tDATA NILAI MAHASISWA 2013\n";
cout<<"===============================================\n";
cout<<"No. Nim Nama Nilai Ket\n";
cout<<"===============================================\n";
}
char *ket(float nilai)
{
if(nilai>=70)
return "Lulus"; //fungsi return
else
return "Gagal";
}
main()
{
int i,y,jumlah;
char input;
struct // -> posisi structure
{ // struct
char nim[15],nama[15],*ket[15]; // {
float nilai; // elemen_structure;
}mahasiswa[5]; // }nama_tipe_struktur[array];
clrscr();
program:
cout<<"Masukkan Nilai data mahasiswa : ";cin>>jumlah;
cout<<endl;
for(i=1;i<=jumlah;i++){
cout<<"Data Ke - "<<i<<endl; // -> structure mahasiswa
cout<<"masukkan NIM : ";cin>>mahasiswa[i].nim;
cout<<"masukkan Nama : ";gets(mahasiswa[i].nama);
cout<<"masukkan Nilai : ";cin>>mahasiswa[i].nilai;
cout<<endl;
y=18; // -> ini dalam menentukan kolom, di dalam penempatan input
}
kolom();
for(i=1;i<=jumlah;i++){
gotoxy(1,y);cout<<i; //tanpa <iomanip.h>
gotoxy(9,y);cout<<mahasiswa[i].nim; //menggunakan gotoxy(x,y);cout<<...;
gotoxy(17,y);cout<<mahasiswa[i].nama;
gotoxy(25,y);cout<<mahasiswa[i].nilai;
gotoxy(33,y);cout<<ket(mahasiswa[i].nilai); //pemanggilannya seperti ini.
y++; // -> ini syarat agar tampilan terjadi perulangan
cout<<endl;
}
garis();
cout<<"Mau Input Data Lagi [Y/T]? ";cin>>input;
if(input=='Y'||input=='y')
goto program;
else
cout<<"\nTERIMA KASIH ANDA TELAH BELAJAR BORLAND C++\n";
getch();
}
Tugas UTS 2013 Borland C++
#include <conio.h>
#include <iostream.h>
main()
{
char koka,tp[10],noka[10],*nkamar,lagi;
int lama,harga,bayar,kembali,total;
program:
clrscr();
cout<<"\t\tPenginapan \"Bochi-Ank\"\n";
cout<<"======================================\n";
cout<<"Type Kamar <single/double/family>: ";cin>>tp;
cout<<"Kode Kamar <D/R/V> : ";cin>>koka;
cout<<"No Kamar : ";cin>>noka;
cout<<"Lama Inap : ";cin>>lama;
cout<<"======================================\n";
if (koka=='D'||koka=='d')
{
nkamar="Deluxe";
if(!strcmp(tp,"single")||!strcmp(tp,"SINGLE"))
harga=250000;
else if(!strcmp(tp,"double")||!strcmp(tp,"DOUBLE"))
harga=375000;
else if(!strcmp(tp,"family")||!strcmp(tp,"FAMILY"))
harga=500000;
else
harga=0;
}
else if (koka=='R'||koka=='r')
{
nkamar="Resident Suite";
if(!strcmp(tp,"single")||!strcmp(tp,"SINGLE"))
harga=350000;
else if(!strcmp(tp,"double")||!strcmp(tp,"DOUBLE"))
harga=575000;
else if(!strcmp(tp,"family")||!strcmp(tp,"FAMILY"))
harga=750000;
else
harga=0;
}
else if (koka=='V'||koka=='v')
{
nkamar="VIP";
if(!strcmp(tp,"single")||!strcmp(tp,"SINGLE"))
harga=175000;
else if(!strcmp(tp,"double")||!strcmp(tp,"DOUBLE"))
harga=300000;
else if(!strcmp(tp,"family")||!strcmp(tp,"FAMILY"))
harga=450000;
else
harga=0;
}
else
{
nkamar="KODE YANG ANDA MASUKKAN SALAH";
if(!strcmp(tp,"single")||!strcmp(tp,"SINGLE"))
harga=0;
else if(!strcmp(tp,"double")||!strcmp(tp,"DOUBLE"))
harga=0;
else if(!strcmp(tp,"family")||!strcmp(tp,"FAMILY"))
harga=0;
else
harga=0;
}
total=harga*lama;
cout<<"Type Kamar : "<<tp<<endl;
cout<<"KOde Kamar : "<<koka<<endl;
cout<<"Nama Kamar : "<<nkamar<<endl;
cout<<"Nomer Kamar : "<<noka<<endl;
cout<<"Harga Kamar : "<<harga<<endl;
cout<<"Total Bayar : "<<total<<endl;
cout<<"======================================\n";
cout<<"Masukkan Uang Bayar : Rp. ";cin>>bayar;
kembali=bayar-total;
cout<<"Uang Kembali : Rp. "<<kembali<<endl<<endl;
cout<<"Input Data Lagi [Y/T] : ";cin>>lagi;
if(lagi=='Y'||lagi=='y')
goto program;
else
goto keluar;
keluar:
}
#include <iostream.h>
main()
{
char koka,tp[10],noka[10],*nkamar,lagi;
int lama,harga,bayar,kembali,total;
program:
clrscr();
cout<<"\t\tPenginapan \"Bochi-Ank\"\n";
cout<<"======================================\n";
cout<<"Type Kamar <single/double/family>: ";cin>>tp;
cout<<"Kode Kamar <D/R/V> : ";cin>>koka;
cout<<"No Kamar : ";cin>>noka;
cout<<"Lama Inap : ";cin>>lama;
cout<<"======================================\n";
if (koka=='D'||koka=='d')
{
nkamar="Deluxe";
if(!strcmp(tp,"single")||!strcmp(tp,"SINGLE"))
harga=250000;
else if(!strcmp(tp,"double")||!strcmp(tp,"DOUBLE"))
harga=375000;
else if(!strcmp(tp,"family")||!strcmp(tp,"FAMILY"))
harga=500000;
else
harga=0;
}
else if (koka=='R'||koka=='r')
{
nkamar="Resident Suite";
if(!strcmp(tp,"single")||!strcmp(tp,"SINGLE"))
harga=350000;
else if(!strcmp(tp,"double")||!strcmp(tp,"DOUBLE"))
harga=575000;
else if(!strcmp(tp,"family")||!strcmp(tp,"FAMILY"))
harga=750000;
else
harga=0;
}
else if (koka=='V'||koka=='v')
{
nkamar="VIP";
if(!strcmp(tp,"single")||!strcmp(tp,"SINGLE"))
harga=175000;
else if(!strcmp(tp,"double")||!strcmp(tp,"DOUBLE"))
harga=300000;
else if(!strcmp(tp,"family")||!strcmp(tp,"FAMILY"))
harga=450000;
else
harga=0;
}
else
{
nkamar="KODE YANG ANDA MASUKKAN SALAH";
if(!strcmp(tp,"single")||!strcmp(tp,"SINGLE"))
harga=0;
else if(!strcmp(tp,"double")||!strcmp(tp,"DOUBLE"))
harga=0;
else if(!strcmp(tp,"family")||!strcmp(tp,"FAMILY"))
harga=0;
else
harga=0;
}
total=harga*lama;
cout<<"Type Kamar : "<<tp<<endl;
cout<<"KOde Kamar : "<<koka<<endl;
cout<<"Nama Kamar : "<<nkamar<<endl;
cout<<"Nomer Kamar : "<<noka<<endl;
cout<<"Harga Kamar : "<<harga<<endl;
cout<<"Total Bayar : "<<total<<endl;
cout<<"======================================\n";
cout<<"Masukkan Uang Bayar : Rp. ";cin>>bayar;
kembali=bayar-total;
cout<<"Uang Kembali : Rp. "<<kembali<<endl<<endl;
cout<<"Input Data Lagi [Y/T] : ";cin>>lagi;
if(lagi=='Y'||lagi=='y')
goto program;
else
goto keluar;
keluar:
}
Langganan:
Postingan (Atom)
Hello World
"
"
"
"