outputnya
COde nya:
Classmahasiswa
{
//atribute
privatedouble
_nuas;
privatedouble
_nuts;
privatedouble
_ntugas;
privatedouble
_npart;
privatedouble
_nakhir;
privatestring
_huruf;
publicdouble
nuas
{
get { return _nuas; }
set {
_nuas = value; }
}
publicdouble
nuts
{
get { return _nuts; }
set {
_nuts = value; }
}
publicdouble
npart
{
get { return _npart; }
set {
_npart = value; }
}
publicdouble
ntugas
{
get { return _ntugas; }
set {
_ntugas = value; }
}
publicdouble HitungNilaiAkhir(double nt, double np,
double nuas, double
nuts)
{
return 0.2 * nt + 0.3 * np + 0.3 * nuas + 0.2 * nuts;
}
publicstring konversiHuruf(double
na)
{
string nh = "";
if (na > 85 && na <= 100)
{
nh = "A";
}
if (na > 80 && na <= 85)
{
nh = "A-";
}
if (na > 75 && na <= 80)
{
nh = "B+";
}
if (na > 70 && na <= 75)
{
nh = "B";
}
if (na > 65 && na <= 70)
{
nh = "B-";
}
if (na > 60 && na <= 65)
{
nh = "C+";
}
if (na > 55 && na <= 60)
{
nh = "C";
}
if (na > 50 && na <= 55)
{
nh = "C-";
}
if (na > 40 && na <= 50)
{
nh = "D";
}
if (na <= 40)
{
nh = "E";
}
return nh;
}
publicvoid tampilkan()
{
Console.WriteLine("-----------------------------------------------");
Console.WriteLine("Menghitung
Nilai Akhir Mata Kuliah");
Console.WriteLine("-----------------------------------------------");
Console.Write("nilai
tugas = ");
_ntugas = double.Parse(Console.ReadLine());
Console.Write("nilai
part = ");
_npart = double.Parse(Console.ReadLine());
Console.Write("nilai
UTS = ");
_nuts = double.Parse(Console.ReadLine());
Console.Write("nilai
UAS = ");
_nuas = double.Parse(Console.ReadLine());
Console.WriteLine("-----------------------------------------------");
_nakhir = HitungNilaiAkhir(_ntugas,
_npart, _nuas, _nuts);
Console.Write("nilai
akhir = " + _nakhir);
Console.WriteLine();
Console.WriteLine("-----------------------------------------------");
_huruf = konversiHuruf(_nakhir);
Console.Write("nilai
huruf = " + _huruf);
}
}
classProgram
{
staticvoid Main(string[]
args)
// membuat objek
mahasiswa m1 = newmahasiswa();
m1.tampilkan();
Console.ReadKey();
}
}
}
Tidak ada komentar:
Posting Komentar