Membuat Program Mahasiswa dengan C++


Salam blogger, pada kesempatan ini kita akan belajar bagaimana membuat sebuah program untuk menentukan indeks prestasi mahasiswa dalam mengikuti sebuah mata kuliah tertentu.

// Exe-3.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#define A 50
using namespace std;


int _tmain(int argc, _TCHAR* argv[])
{
	char ulang;
	do {
		system("cls");
		int nh[A];
		int uts[A];
		int tm[A];
		int uas[A];
		int i,n;
		double rt[A];
		char grade[A];

		cout << "\tMasukkan jumlah data = "; cin >> n;
		cout << "---------------------------------------------------------------\n";
		for( i=0; i<n; i++ ) {
			
			cout << "Nilai Kehadiran      = "; cin >> nh[i];
			cout << "NIlai UTS            = "; cin >> uts[i];
			cout << "Nilai TM             = "; cin >> tm[i];
			cout << "Nilai UAS            = "; cin >> uas[i];
			cout << "---------------------------------------------------------------\n";
		}

		system("cls");
		cout << "---------------------------------------------------------------------\n";
		cout << "NO\tKehadiran\tUTS\tTM\tUAS\tRata-rata\tGrade\n";
		cout << "---------------------------------------------------------------------\n";
		for( i=0; i<n; i++ ) {
			rt[i] = (0.1*+nh[i]) + (0.25*uts[i]) + (0.15*tm[i]) + (0.5*uas[i]);
			if( rt[i] >= 80 ) { grade[i] = 'A'; }
			else if( rt[i] >= 70 && rt[i] < 80 ) { grade[i] = 'B'; }
			else if( rt[i] >= 60 && rt[i] < 70 ) { grade[i] = 'C'; }
			else if( rt[i] >= 50 && rt[i] < 60 ) { grade[i] = 'D'; }
			else { grade[i] = 'E'; }

			cout << i << "\t" << nh[i] << "\t\t" << uts[i] << "\t" << tm[i] << "\t" << uas[i] << "\t" << rt[i] << "\t\t" << grade[i] << "\n\n";

		}		
		cout << "\tMau coba lagi [Y/T] = "; cin >> ulang;

	} while( (ulang == 'y') || (ulang == 'Y') );
	return 0;
}

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s