Minggu, 26 Mei 2013

Program Menghitung Nilai Akhir (Array) dengan C++

#include <conio.h>
#include <iostream.h>
#include <iomanip.h>

void main()
{
    cout<<"\n\n\t================================================";
    cout<<"\n\tNAMA    : HAPSARI RATNA MANDALAWATI";
   cout<<"\n\tNIM    : 2012-51-108";
   cout<<"\n\t================================================\n";
   getch();

   clrscr();
   cout<<"\n\n\t================================================";
    cout<<"\n\t          PROGRAM MENGHITUNG NILAI AKHIR";
   cout<<"\n\t          MATA KULIAH BAHASA PEMPROGRAMAN";
   cout<<"\n\t================================================\n";
   getch();

   int jm;
   cout<<"\n\tMASUKKAN JUMLAH MAHASISWA : ";
   cin>>jm;

   char nama[50][100];
   int tugas[50];
   int uts[50];
   int uas[50];
   int akhir[50];

   for(int i=1; i<=jm; i++)
   {

      cout<<"\n"<<endl;
      cout<<"\tMAHASISWA KE-"<<i<<endl;
      cout<<"\t-------------------------------\n"<<endl;
      cout<<"\tNAMA MAHASISWA    : ";
      cin>>nama[i];
      cout<<"\tNILAI TUGAS     : ";
      cin>>tugas[i];
      cout<<"\tNILAI UTS       : ";
      cin>>uts[i];
      cout<<"\tNILAI UAS       : ";
      cin>>uas[i];
      akhir[i]=(tugas[i]*0.3)+(uts[i]*0.2)+(uas[i]*0.5);
   }
   getch();

   clrscr();
    cout<<" \t--------------------------------------------------------------- "<<endl;
    cout<<" \t                       DAFTAR NILAI "<<endl;
    cout<<" \t              MATAKULIAH : BAHASA PEMROGRAMAN "<<endl;
    cout<<" \t--------------------------------------------------------------- "<<endl;
    cout<<" \tNo.   Nama                         Nilai               Grade "<<endl;
    cout<<" \t      Mahasiswa       ------------------------------"<<endl;
    cout<<" \t                       Tugas    UTS    UAS    Akhir  "<<endl;
    cout<<" \t--------------------------------------------------------------- "<<endl;
    for (int i=1;i<=jm;i++)
        {
            cout<<setw (11)<<i;
            cout<<setw (13)<<nama[i];
            cout<<setw (12)<<tugas [i];
            cout<<setw (7)<<uts [i];
            cout<<setw (7)<<uas [i];
            cout<<setw (9)<<akhir [i];

            if (akhir[i]>=80)
               cout<<setw (7)<<"A";
               else if (akhir[i]>=70)
               cout<<setw (7)<<"B";
               else if (akhir[i]>=60)
               cout<<setw (7)<<"C";
               else if (akhir[i]>=50)
               cout<<setw (7)<<"D";
               else if (akhir[i]<50)
               cout<<setw (7)<<"E";

            cout<<endl;

        }
        cout<<" \t--------------------------------------------------------------- "<<endl;
        cout<<" \n\tTOTAL MAHASISWA = "<<jm<<endl;

    getch();
   }

Hasilnya =>