Kamis, 05 Desember 2013

contoh program c++ menu data maha siswa

/*
    Title            :    ProjMid3_by_ kurniawan
    Author            :    Kurniawan
    Latest Update    :    October, 27th 2013
*/

#include "stdafx.h"
#include "iostream"
#include "cstdlib"
#include "iomanip"
#include "conio.h"
#include "stdio.h"
#include "windows.h"
#include <string>
#define br <<endl;
using namespace std;


void xy(int x, int y){
    HANDLE hConsole=GetStdHandle(STD_OUTPUT_HANDLE);
    _COORD pos;
    pos.X=x;
    pos.Y=y;
    SetConsoleCursorPosition(hConsole, pos);
}

string nama,prodi,jenjang;
string mapel[];
int opt,npm,menu,i,j,x,y,hTb,wTb,jml_matkul;


int main(){  

    HANDLE color=GetStdHandle(STD_OUTPUT_HANDLE);
start_menu:
    system("cls");
    SetConsoleTextAttribute(color,14);
    cout<<"\n        \1\1\1      :: PROJECT MID SEMESTER 3 [ SUBMISSION ] ::      \1\1\1       \n";
    cout<<"        \1\1\1    ::        By Yana Setiono - MSB GROUP        ::    \1\1\1       \n";
    SetConsoleTextAttribute(color,7);
    cout<<"================================================================================" br;
    SetConsoleTextAttribute(color,7);cout<<"DAFTAR MENU(S) :\n" br;
    SetConsoleTextAttribute(color,15);
//    cout <<"Masukan Nama anda : ";getline(cin , nama);
    cout<<"1. CETAK KTM " br;
    cout<<"2. CETAK KRS " br;
    cout<<"3. CETAK KHS " br;
    cout<<"4. CETAK KBA " br;
    cout<<"5. CETAK KARTU PERPUSTAKAAN" br;
    cout<<"6. CV MAHASISWA" br;
    cout<<"\n -> JALANKAN PROGRAM NOMOR : ";cin>>menu;
    switch(menu){
        case 1:{
            /* PROGRAM KTM */
start_ktm:
    system("cls");

    cout<<"CETAK KARTU TANDA MAHASISWA \n";
    SetConsoleTextAttribute(color,10);cout<<" -> NPM      : ";
    SetConsoleTextAttribute(color,15);cin>>npm;  
    SetConsoleTextAttribute(color,10);cout<<" -> NAMA     : " ;
    cin.ignore();
    SetConsoleTextAttribute(color,15);getline(cin,nama);
    SetConsoleTextAttribute(color,10);cout<<" -> PRODI    : ";
    SetConsoleTextAttribute(color,15);getline(cin,prodi);
    SetConsoleTextAttribute(color,10);cout<<" -> JENJANG  : ";
    SetConsoleTextAttribute(color,15);getline(cin,jenjang);
    system("cls");
    cout<<"\n";
    SetConsoleTextAttribute(color,15);
    cout<<"  : : ::  : : :   :   ::: : : ::: ::: :::: :::  ::: ::: :: ::         \n";
    cout<<"  : : : : : :  : :    :.: : :  :  :.. :.:  :.:  :-:  :  : : :  \n";
    cout<<"  ::: :  :: :   :   : :   :::  :  :.. :  : : :  :::  :  :   :  \n";
    SetConsoleTextAttribute(color,7);
    cout<<"_______________________________________________________________ \n" br;
    SetConsoleTextAttribute(color,11);
    cout<<"                  K A R T U  M A H A S I S W A                         \n\n";
    SetConsoleTextAttribute(color,15);
    cout<<"\n    :::::::::   Nama       :  "<<nama;
    cout<<"\n    : ~   ~ :   NPM        :  "<<npm;
    cout<<"\n     :  '  :    Prodi      :  "<<prodi;
    cout<<"\n    :::::::::   Jenjang    :  "<<jenjang;
    SetConsoleTextAttribute(color,7);
    cout<<"\n\n               Masa studi sampai dengan 2016\n\n" br;
    SetConsoleTextAttribute(color,7);
    cout<<"_______________________________________________________________ \n" br;
obc1: // Option Back Case 1
    SetConsoleTextAttribute(color,10);
    cout<<"Input 1 = Lanjut , 0 = Menu Utama : ";cin>>opt;
    if(opt==1){
        goto start_ktm;
    }else if(opt==0){
        goto start_menu;
    }else{
        goto obc1;
    }
        /* END PROGRAM KTM */
       } break;
/* CASE 1 FINISH WELL */
      
        case 2:{
        /* PROGRAM KRS */
      
        system("cls");
        cout<<"Sorry... \n This program is now under maintenance \n Thanks\n MSB Group\n\n";
        cout<<"Input 1 [ Kembali ] :";cin>>opt;
obc2: // Option Back Case 2
        if(opt==1){ goto start_menu; }else{ goto obc2; }
        /* END PROGRAM KRS */
       }break;
/* CASE 2 FINISH WELL */
        case 3:{ // KHS
            system("cls");
            char title[70]="\5 KARTU HASIL STUDI <::> UNIVERSITAS PUTERA BATAM \5";
            wTb=80;
            x=-1; y=2;
            xy((wTb-strlen(title))/2,1);printf(title);
            for(i=1;i<=wTb;i++){ xy(x+i,y);cout<<"="; }
            // INPUT DATA MAHASISWA
            SetConsoleTextAttribute(color,10);
            xy(2,y+1);cout<<" > NPM      : ";
            xy(2,y+2);cout<<" > NAMA     : " ;
            SetConsoleTextAttribute(color,15);
            xy(16,y+1);cin>>npm;
            cin.ignore(); // anyway it's needed to use getline
            xy(16,y+2);getline(cin,nama);
            SetConsoleTextAttribute(color,7);
            for(i=1;i<=50;i++){ xy(x+i,y+3);cout<<"-";    }
            SetConsoleTextAttribute(color,10);cout<<"\n > Jumlah Mata Kuliah Yang diambil : ";
            SetConsoleTextAttribute(color,7);cin>>jml_matkul;
            // Declaration for score
            int max=jml_matkul;
            int* nil_tm=new int[max];
            int* nil_uts=new int[max];
            int* nil_uas=new int[max];
            //
            for(i=1;i<=jml_matkul;i++){
                SetConsoleTextAttribute(color,13);
                cout<<" Matkul ke- "<<i br;
                SetConsoleTextAttribute(color,15);
                cout<<"     > Nilai TM  : " ;cin>>nil_tm[i];
                cout<<"     > Nilai UTS : " ;cin>>nil_uts[i];
                cout<<"     > Nilai UAS : " ;cin>>nil_uas[i];
                SetConsoleTextAttribute(color,7);
                cout<<"_________________________________________\n";
            }
            cout<<"\n";
            // THESE LINES BELOW ARE ONLY FOR TESting
            for(i=1;i<=jml_matkul;i++){
                SetConsoleTextAttribute(color,8);
                cout<<" Matkul ke- "<<i br;
                SetConsoleTextAttribute(color,15);
                cout<<"     > Nilai TM  : "<<nil_tm[i];
                cout<<"     > Nilai UTS : "<<nil_uts[i];
                cout<<"     > Nilai UAS : "<<nil_uas[i];
                SetConsoleTextAttribute(color,7);
                cout<<"_________________________________________";
            }
            //SetConsoleTextAttribute(color,10);
            cout<<"\n";          
            // TITLE WILL SET TO CENTER OF HEADER
            //xy((wTb-title.length())/2,1);puts(title) br;

            cout<<"\n\n Sorry... \n This program is now under maintenance \n Thanks\n MSB Group\n\n";
            cout<<"Input 1 [ Kembali ] :";cin>>opt;
obc3: // Option Back Case 3
        if(opt==1){ goto start_menu; }else{ goto obc3; }
        /* END PROGRAM KHS */
        }break;
        default : cout<<"Menu yang anda pilih tidak tersedia"; goto start_menu;

    } // END CASE

    system("pause");
    return 0;
}

program sederhana

#include "stdafx.h"
#include <iostream>
#include "cstdlib"
#include "iomanip"
#include "conio.h"
#include "stdio.h"
#include "windows.h"
#include <string>
#define br <<endl;
using namespace std;


int main()

{
    system("cls");
    HANDLE color=GetStdHandle(STD_OUTPUT_HANDLE);
char menu;
    cout<<endl;
    SetConsoleTextAttribute(color,8);cout<<"       =========================================="<<endl;
    SetConsoleTextAttribute(color,9);cout<<"       >>>||Selamat Datang Tugas Tekstruktur ||<<<"<<endl;
    SetConsoleTextAttribute(color,8);cout<<"       =========================================="<<endl;
    cout<<endl;
    SetConsoleTextAttribute(color,10);cout<<"    Nama : Kurniawan "<<endl;
    SetConsoleTextAttribute(color,10);cout<<"    Npm  : 120210098 "<<endl;
    cout<<endl;
    SetConsoleTextAttribute(color,13);cout<<"          ================="<<endl;
    SetConsoleTextAttribute(color,12);cout<<"          |  MENU SAYA    |"<<endl;
    SetConsoleTextAttribute(color,13);cout<<"          ================="<<endl;
    cout<<endl;
    SetConsoleTextAttribute(color,15);cout<<"   click (1,2,3,4,5)      ->"<<endl;
    cout<<"      ______________________________"<<endl;
    cout<<"      |  1. Luas dan volume Bola   |"<<endl;
    cout<<"      |  2. Luas dan volume Kubus  |"<<endl;
    cout<<"      |  3. Luas dan volume Kerucut|"<<endl;
    cout<<"      |  4. Luas dan volume Limas  |"<<endl;
    cout<<"      |  5. Luas dan volume Tabung |"<<endl;
    cout<<"      |  6. Pesan kurniawan        |"<<endl;
    cout<<"      ______________________________"<<endl;
    cout<<endl;
    SetConsoleTextAttribute(color,11);cout<<"\n -> Jalankan Menu Nomor : ";cin>>menu;
    cout<<endl;
    switch (menu)
    {
    case '1':
        {
        cout<<" 1. BOLA"<<endl;
        cout<<"___________________________________"<<endl;
        cout<<endl;
        cout<<">>>  Pencarian Volume dan luas bola"<<endl;
        cout<<"___________________________________"<<endl;
        cout<<endl;
    float volume,luas,r;
        cout<<" Input jari-jari=  ";cin>>r;
        cout<<endl;
        volume=4*3.14*r*r*r;
        cout<<" Jadi Volume bola adalah=  ";
        cout<<volume<<endl;
        luas=1.33*3.14*r*r*r;
        cout<<endl;
        cout<<" Jadi luas bola adalah  =  ";
        cout<<luas<<endl;
        cout<<endl;
    }
    break;
    case '2':
        {
        cout<<"  2. KUBUS"<<endl;
        cout<<"___________________________________"<<endl;
        cout<<endl;
        cout<<">>>  Pencarian Volume dan Luas Kubus"<<endl;
        cout<<"___________________________________"<<endl;
        cout<<endl;
    float kubus,volume,luas,sisi;
        cout<<" Input sisi kubus =  ";cin>>sisi;
        cout<<endl;
        volume=6*sisi*sisi;
        cout<<" jadi volume kubus adalah= ";
        cout<<volume<<endl;
        cout<<endl;
        luas=sisi*sisi*sisi;
        cout<<" Jadi luas kubus adalah= ";
        cout<<luas<<endl;
    }
    break;
    case '3':
        {
        cout<<"  3. KERUCUT"<<endl;
        cout<<"__________________________________"<<endl;
        cout<<endl;
        cout<<">>> Pencarian Volume dan Luas"<<endl;
        cout<<endl;
        cout<<"__________________________________"<<endl;
        cout<<endl;
    float luas,volume,la,ls,t,r;
        cout<<" Input luas alas   =  ";cin>>la;
        cout<<" Input luas selimut=  ";cin>>ls;
        cout<<" input tinggi      =  ";cin>>t;
        cout<<" input jari-jari   =  ";cin>>r;
        cout<<endl;
        luas=la*ls;
        cout<<" jadi luas kerucut adalah= ";
        cout<<luas<<endl;
        volume=0.33*3.14*r*r*t;
        cout<<endl;
        cout<<" jadi Volume kerucut adalah= ";
        cout<<volume<<endl;
        cout<<endl;
    }
    break;
    case '4':
        {
        cout<<"  4. LIMAS"<<endl;
        cout<<"__________________________________"<<endl;
        cout<<endl;
        cout<<">>> Pencarian Volume dan Luas Limas "<<endl;
        cout<<endl;
        cout<<"__________________________________"<<endl;
        cout<<endl;
    float la,jst,volume,luas;
        cout<<" Input sisi tegak= ";cin>>jst;
        cout<<" Input luas alas = ";cin>>la;
        cout<<endl;
        luas=la*jst;
        cout<<" jadi luas Limas adalah= ";
        cout<<luas<<endl;
        volume=0.33*jst;
        cout<<" jadi volume Limas Adalah= ";
        cout<<volume<<endl;
        cout<<endl;
    }
    break;
    case '5':
        {
        cout<<"  5. TABUNG"<<endl;
        cout<<"__________________________________"<<endl;
        cout<<endl;
        cout<<">>> Pencarian Volume dan Luas Tabung "<<endl;
        cout<<endl;
        cout<<"__________________________________"<<endl;
        cout<<endl;
        float la,lt,ls,t,volume,luas;
        cout<<"  input tinggi        = ";cin>>t;
        cout<<"  input luas tutup    = ";cin>>lt;
        cout<<"  input luas selimut  = ";cin>>ls;
        cout<<"  input luas alas     = ";cin>>la;
        cout<<endl;
        luas=la*lt*ls;
        cout<<"  jadi luas tabung adalah= ";
        cout<<luas<<endl;
        cout<<endl;
        volume=la*t;
        cout<<" jadi volume tabung adalah= ";
        cout<<volume<<endl;
  
    }
    break;
    case '6':
        cout<<"  6. Komentar Penulis"<<endl;
        cout<<"__________________________________"<<endl;
        cout<<endl;
      
        {
        float pesan;
        SetConsoleTextAttribute(color,4);cout<<" Pesan =   Maaf pak saya tak bisa bikin title menu nya alnya tak sempat lagi"<<endl;
        SetConsoleTextAttribute(color,4);cout<<"         cos kayak gini lah bisa nya pak, lupa rumus nya, kayak mana kayak mana"<<endl;
        SetConsoleTextAttribute(color,4);cout<<"         cara sipaya program kita bisa lau di input balek ke menu awal"<<endl;
        cout<<endl;
        }

    }
    system("pause");
    return 0;
}




Program