Array Dua(2) Dimensi menampilkan rata" tiap Mahasiswa dan tiap Mata kuliah
#include <iostream>
#include <conio.h>
#include <iomanip>
#include <string>
using namespace std;
int main()
{
string nama[5] = {"Andi" , "Melissa", "Herman", "Joko", "Wayan"};
string matkul[5] = {"Fisika" , "Matematika" , "Kimia" , "Biologi"};
int numb, i;
float nilaiF[5] = {84, 76, 54, 46, 76};//code y = 0
float nilaiM[5] = {84, 66, 84, 66, 66};//code y = 1
float nilaiK[5] = {94, 76, 54, 86, 66};//code y = 2
float nilaiB[5] = {64, 86, 84, 76, 76};//code y = 3
//==========================================================================
//*********************Storage DataBase Array 2 dimensi*********************
//==========================================================================
//keterangan:
// **[x][y] x untuk nilai satu nama; y untuk nama setiap matakuliah....
float nilai[10][10];
nilai[0][0]= 84;//andi x = 0 (code)
nilai[0][1]= 84;
nilai[0][2]= 94;
nilai[0][3]= 64;
nilai[1][0]= 76;//melisa x = 1 (code)
nilai[1][1]= 66;
nilai[1][2]= 76;
nilai[1][3]= 86;
nilai[2][0]= 54;//herman x = 2 (code)
nilai[2][1]= 84;
nilai[2][2]= 54;
nilai[2][3]= 84;
nilai[3][0]= 46;//joko x = 3 (code)
nilai[3][1]= 66;
nilai[3][2]= 86;
nilai[3][3]= 76;
nilai[4][0]= 76;//wayan x = 4 (code)
nilai[4][1]= 66;
nilai[4][2]= 66;
nilai[4][3]= 76;
//==========================================================================
//***************************Hanya Tampilan Tabel***************************
//==========================================================================
cout<<"|=======================================================|";
cout<<"\n|=====Nama======|===============Nilai===================|"<<endl;
cout<<"|\t\t|Fisika\t Matematika\tKimia\tBiologi\t|"<<endl;
cout<<"| |=======================================|"<<endl;
numb=1;
for( i=0; i<5; i++ )
{
cout <<"|"<<numb<<"."<<nama[i]<<setw(6)<<"\t|"<<setw(4)<<nilaiF[i]<<"\t"<<setw(8)<<nilaiM[i]<<"\t "
<<nilaiK[i]<<"\t "<<nilaiB[i]<<"\t|"<<endl;
numb++;
}//end
cout<<"|=======================================================|"<<endl;
//==========================================================================
//***********************Modul rata-rata tiap mahasiswa*********************
//==========================================================================
cout<<"Rata-rata Tiap Mahasiswa: "<<endl;
cout<<"\n";
float total, average_tp_siswa;
int x, y;
int counter;
total= 0;
for( x=0; x<5; x++ )
{
counter =0;
for( y=0; y<4; y++ )
{
total = total + nilai[x][y];
counter++;
}//end
average_tp_siswa = total/counter;
cout<<"Rata-rata "<<nama[x]<<setw(4)<<"\t"<<average_tp_siswa<<endl;
total = 0;
}//end
//==========================================================================
//***********************Modul Rata-rata tiap Matkul************************
//==========================================================================
cout<<"\nRata-rata Tiap Matakuliah: "<<endl;
cout<<"\n";
float average_tp_matkul;
total = 0;
for( y=0; y<4; y++ )
{
counter = 0;
for( x=0; x<5; x++ )
{
total = total + nilai[x][y];
counter++;
}//end
average_tp_matkul = total/counter;
cout<<"Rata-rata "<<matkul[y]<<setw(4)<<"\t"<<average_tp_matkul<<endl;
total = 0;
}//end
//Personal copyright;
//Buatan sendiri....
cout<<"\n\n=========================================================="<<endl;
cout<<"{c}copyright :@Tom Richard Simatupang";
//==========================================================================
//ENDDDDDDDDD&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
//==========================================================================
getch();
}
#include <conio.h>
#include <iomanip>
#include <string>
using namespace std;
int main()
{
string nama[5] = {"Andi" , "Melissa", "Herman", "Joko", "Wayan"};
string matkul[5] = {"Fisika" , "Matematika" , "Kimia" , "Biologi"};
int numb, i;
float nilaiF[5] = {84, 76, 54, 46, 76};//code y = 0
float nilaiM[5] = {84, 66, 84, 66, 66};//code y = 1
float nilaiK[5] = {94, 76, 54, 86, 66};//code y = 2
float nilaiB[5] = {64, 86, 84, 76, 76};//code y = 3
//==========================================================================
//*********************Storage DataBase Array 2 dimensi*********************
//==========================================================================
//keterangan:
// **[x][y] x untuk nilai satu nama; y untuk nama setiap matakuliah....
float nilai[10][10];
nilai[0][0]= 84;//andi x = 0 (code)
nilai[0][1]= 84;
nilai[0][2]= 94;
nilai[0][3]= 64;
nilai[1][0]= 76;//melisa x = 1 (code)
nilai[1][1]= 66;
nilai[1][2]= 76;
nilai[1][3]= 86;
nilai[2][0]= 54;//herman x = 2 (code)
nilai[2][1]= 84;
nilai[2][2]= 54;
nilai[2][3]= 84;
nilai[3][0]= 46;//joko x = 3 (code)
nilai[3][1]= 66;
nilai[3][2]= 86;
nilai[3][3]= 76;
nilai[4][0]= 76;//wayan x = 4 (code)
nilai[4][1]= 66;
nilai[4][2]= 66;
nilai[4][3]= 76;
//==========================================================================
//***************************Hanya Tampilan Tabel***************************
//==========================================================================
cout<<"|=======================================================|";
cout<<"\n|=====Nama======|===============Nilai===================|"<<endl;
cout<<"|\t\t|Fisika\t Matematika\tKimia\tBiologi\t|"<<endl;
cout<<"| |=======================================|"<<endl;
numb=1;
for( i=0; i<5; i++ )
{
cout <<"|"<<numb<<"."<<nama[i]<<setw(6)<<"\t|"<<setw(4)<<nilaiF[i]<<"\t"<<setw(8)<<nilaiM[i]<<"\t "
<<nilaiK[i]<<"\t "<<nilaiB[i]<<"\t|"<<endl;
numb++;
}//end
cout<<"|=======================================================|"<<endl;
//==========================================================================
//***********************Modul rata-rata tiap mahasiswa*********************
//==========================================================================
cout<<"Rata-rata Tiap Mahasiswa: "<<endl;
cout<<"\n";
float total, average_tp_siswa;
int x, y;
int counter;
total= 0;
for( x=0; x<5; x++ )
{
counter =0;
for( y=0; y<4; y++ )
{
total = total + nilai[x][y];
counter++;
}//end
average_tp_siswa = total/counter;
cout<<"Rata-rata "<<nama[x]<<setw(4)<<"\t"<<average_tp_siswa<<endl;
total = 0;
}//end
//==========================================================================
//***********************Modul Rata-rata tiap Matkul************************
//==========================================================================
cout<<"\nRata-rata Tiap Matakuliah: "<<endl;
cout<<"\n";
float average_tp_matkul;
total = 0;
for( y=0; y<4; y++ )
{
counter = 0;
for( x=0; x<5; x++ )
{
total = total + nilai[x][y];
counter++;
}//end
average_tp_matkul = total/counter;
cout<<"Rata-rata "<<matkul[y]<<setw(4)<<"\t"<<average_tp_matkul<<endl;
total = 0;
}//end
//Personal copyright;
//Buatan sendiri....
cout<<"\n\n=========================================================="<<endl;
cout<<"{c}copyright :@Tom Richard Simatupang";
//==========================================================================
//ENDDDDDDDDD&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
//==========================================================================
getch();
}
untuk menghitung nilai maximal dari program tersebut gimana ya kak
BalasHapus