Dibawah ini adalah contoh program array dengan menggunakan bahasa C#.
using System;
namespace Array_024
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
//
// TODO: Add code to start application here
//
int r,x;
string status;
double []p=new double[5];
double []q=new double[5];
double []mean=new double[5];
string []name= new string[50];
Console.Write("How Many Students? ");
r=Convert.ToInt32(Console.ReadLine());
for (x=0;x<r;x++)
{
Console.WriteLine("\nData ke- {0} ",x+1);
Console.Write("Name : ");
name[x]=Console.ReadLine();
Console.Write("Mid Exam : ");
p[x]=Convert.ToDouble(Console.ReadLine());
Console.Write("Final Exam : ");
q[x]=Convert.ToDouble(Console.ReadLine());
}
for (x=0;x<r;x++)
{
mean[x]=(p[x]+q[x])/2;
}
Console.WriteLine("\n\n");
Console.WriteLine("No\tName\t\tMid Exam\tFinal Exam\tAverage\t\tStatus");
Console.WriteLine("------------------------------------------------------------------------------");
for (x=0;x<r;x++)
{
if (mean[x]>=60)
{
Console.WriteLine("{0}\t{1}\t\t{2}\t\t{3}\t\t{4}\t\tOke",x+1,name[x],p[x],q[x],mean[x]);
}
else
{
Console.WriteLine("{0}\t{1}\t{2}\t\t{3}\t\t{4}\t\tNo Oke",x+1,name[x],p[x],q[x],mean[x]);
}
}
Console.ReadLine();
}
}
}
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment