Category: Pemograman


Program c++

ini sedikit dari saya

#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<stdlib.h>
#define N 20
#define M 10
void main()
{
/* Deklerasi Variabel */
clrscr();
char nobp[N][8],nama[N][20];
char mk[N][M][25];
char sks[N][M][3];
char nilai[N][M][3];

int i=1,j,jmlmhs=0,jummk[N];
char lagi;
char bobot[2];
char tb;
char ket[6];
float ts,tm,ip,jb,s;
/* Input Data */
printf(“\nINPUT NILAI MAHASISWA “);
printf(“\n______________________”);
while(1)
{
printf(“\n\nINPUT MAHASISWA KE : %d”,i);
printf(“\n___________________________”);
printf(“\nNo Bp          : “);
gets(&nobp[i][0]);
printf(“\nNama Mahasiswa : “);
gets(&nama[i][0]);
jummk[i]=0;
j=1;
while(1)
{
printf(“\n\nINPUT NILAI MAHASISWA KE : %d”,j);
printf(“\n______________________________”);
printf(“\nMata Kuliah    : “);
gets(&mk[i][j][0]);
printf(“\nSKS            : “);
gets(&sks[i][j][0]);
s=atof(sks[i][j]);
printf(“\nNilai          : “);
gets(&nilai[i][j][0]);
tb=atof(bobot);
jummk[i]=jummk[i]+1;
j++;
printf(“\nADA DATA LAGI      :[Y/T]..?    “);
lagi=getche();
if(lagi==’T’||lagi==’t’)
break;
}
i++;
jmlmhs=jmlmhs+1;
printf(“\nADA MAGASISWA LAGI :[Y/T]..?    “);
lagi=getche();
if(lagi==’T’||lagi==’t’)
break;
}
/* Output Data */
clrscr();
printf(“\nLEMBARAN HASIL NILAI MAHASISWA”);
printf(“\n______________________________\n”);
for(i=1;i<=jmlmhs;i++)
{
printf(“\n NO BP  : %s”,nobp[i]);
printf(“\n NAMA   : %s”,nama[i]);
printf(“\n=================================================”);
printf(“\n Mata Kuliah  \tSKS \tNilai\tBobot\tKeterangan”);
printf(“\n=================================================”);
for(j=1;j<=jummk[i];j++)
{
if (strcmp(nilai[i][j],”a”)==0)
{
strcpy(bobot,”4″);
strcpy(ket,”lulus”);
}
else if (strcmp(nilai[i][j],”b”)==0)
{
strcpy(bobot,”3″);
strcpy(ket,”lulus”);
}
else if(strcmp(nilai[i][j],”c”)==0)
{
strcpy(bobot,”2″);
strcpy(ket,”lulus”);
}
else if(strcmp(nilai[i][j],”d”)==0)
{
strcpy(bobot,”1″);
strcpy(ket,”gagal”);
}
else {
strcpy(bobot,”0″);
strcpy(ket,”gagal”);
}
ts= ts+s;

tm= ts*tb;
ip=tm/ts;

printf(“\n %s          \t%s  \t%s    \t%s \t%s”,mk[i][j],sks[i][j],nilai[i][j],bobot,ket);
}

printf(“\n\n Total Sks             :%2.0f”,ts);
printf(“\n\n total Mutu            :%2.0f”,tm);
printf(“\n\n Indeks Prestasi       :%2.0f”,ip);
}
getch();
}

Iklan

Java

ini mengenai java yang cukup sederhana sekali

public class BukuAlamatTest {
public static void main(String args[]){
BukuAlamat bukuKu= new BukuAlamat();
String namaKu;
String alamatKu;
String telponKu;
String eMailKu;

System.out.println(“\n\tData Satu”);
bukuKu.setInfo(“hengki”);
namaKu=bukuKu.getNama();
bukuKu.cetak();

System.out.println(“\n\tData Dua”);
bukuKu.setInfo(“hengki”,”Jl. Bhakti 2. No 15c”);
namaKu=bukuKu.getNama();
alamatKu=bukuKu.getAlamat();
bukuKu.cetak();

System.out.println(“\n\tData Tiga”);
bukuKu.setInfo(“hengki”,”Jl. Bhakti 2. No 15c”,”0751-8228235″);
namaKu=bukuKu.getNama();
alamatKu=bukuKu.getAlamat();
telponKu=bukuKu.getTelpon();
bukuKu.cetak();

System.out.println(“\n\tData Empat”);
bukuKu.setInfo(“hengki”,”Jl. Bhakti 2. No 15c”,”0751-8228235″,
“hhengki34@yahoo.com”);
namaKu=bukuKu.getNama();
alamatKu=bukuKu.getAlamat();
telponKu=bukuKu.getTelpon();
eMailKu=bukuKu.getEMail();
bukuKu.cetak();

di save = test.java

trus

public class BukuAlamat {
private String nama;
private String alamat;
private String telpon;
private String eMail;

public BukuAlamat(){
nama=”=hengki=”;
alamat=”=jl. Bhakti 2.NO 15c=”;
telpon=”=07518228235=”;
eMail=”=hhengki34@yahoo.com=”;
}

public void setInfo(String nma){
nama=nma;
}

public void setInfo(String nma,String ala){
nama=nma;
alamat=ala;
}

public void setInfo(String nma,String ala,String telp){
nama=nma;
alamat=ala;
telpon=telp;
}

public void setInfo(String nma,String ala,String telp,String mail){
nama=nma;
alamat=ala;
telpon=telp;
eMail=mail;
}

public String getNama(){
return nama;
}

public String getAlamat(){
return alamat;
}

public String getTelpon(){
return telpon;
}

public String getEMail(){
return eMail;
}

public void cetak(){
System.out.println(“Nama      : “+nama);
System.out.println(“Alamat    : “+alamat);
System.out.println(“Telpon    : “+telpon);
System.out.println(“E-Mail    : “+eMail);

}
}

di save =  buku.java