What's new

Help C# program

inggitera

Eternal Poster
hi sir at mam, baka po may pedeng makatulong, nakapagtanong tanong na po kaso wala ganu makasagot.

Using 2D Arrays, create a complete C# program that will accept 10 of your classmates’ names and their Prelim GWA. The program should sort the list based on the highest GWA.

salamat po in advance.
 
Dito ka mag laro

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int num1 = 0, num2 = 0, num3 = 0;

Console.WriteLine("lowest");

Console.WriteLine("input 1st number");
num1 = int.Parse(Console.ReadLine());

Console.WriteLine("input 2nd number");
num2 = int.Parse(Console.ReadLine());

Console.WriteLine("input 3rd number");
num3 = int.Parse(Console.ReadLine());

Console.WriteLine("input 4th number");
num4 = int.Parse(Console.ReadLine());

Console.WriteLine("input 5th number");
num5 = int.Parse(Console.ReadLine());

Console.Clear();



int lowest = ((num1 < num2 ? num1: num2) < num3 ?
(num1 < num2 ? num1 : num2) : num3);
int highest = ((num1 > num2 ? num1: num2) > num3 ?
(num1 > num2 ? num1 : num2) : num3) ;

Console.WriteLine(" lowest is {0} ", lowest);
Console.WriteLine(" highest is {0} ", highest);
Console.ReadLine();
}
}
}

Tapos ang logic base mo Array
Search mo na lang yung array samples then ang main mo is to
put a value as integer
then after that yung value na yun yung pwede mo ilagay variable as "Name" Then set ka ng array kung ano yung GWA ng set ng names

halimbawa

si Jen = variable a
si Ben = variable b
Then
a = [9.1] [8.2] [8]
b = [7.9] [8.4] [9]ganyan lang logic setting array tapos ayan na idea.
 
Last edited:
Dito ka mag laro

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int num1 = 0, num2 = 0, num3 = 0;

Console.WriteLine("lowest");

Console.WriteLine("input 1st number");
num1 = int.Parse(Console.ReadLine());

Console.WriteLine("input 2nd number");
num2 = int.Parse(Console.ReadLine());

Console.WriteLine("input 3rd number");
num3 = int.Parse(Console.ReadLine());

Console.WriteLine("input 4th number");
num4 = int.Parse(Console.ReadLine());

Console.WriteLine("input 5th number");
num5 = int.Parse(Console.ReadLine());

Console.Clear();



int lowest = ((num1 < num2 ? num1: num2) < num3 ?
(num1 < num2 ? num1 : num2) : num3);
int highest = ((num1 > num2 ? num1: num2) > num3 ?
(num1 > num2 ? num1 : num2) : num3) ;

Console.WriteLine(" lowest is {0} ", lowest);
Console.WriteLine(" highest is {0} ", highest);
Console.ReadLine();
}
}
}

Tapos ang logic base mo Array
Search mo na lang yung array samples then ang main mo is to
put a value as integer
then after that yung value na yun yung pwede mo ilagay variable as "Name" Then set ka ng array kung ano yung GWA ng set ng names

halimbawa

si Jen = variable a
si Ben = variable b
Then
a = [9.1] [8.2] [8]
b = [7.9] [8.4] [9]ganyan lang logic setting array tapos ayan na idea.
salamat po dito, sir pakitingin po ito ginawa ko.
using System;

namespace Act124
{
class Program
{
static void Main(string[] args)
{
string[,] n = new string[10, 1];

int[,] gwa = new int[10, 1];

n[0, 0] = Console.ReadLine();

for (int a = 0; a < n.GetUpperBound(1); a++)
{
for (int b = 0; b < n.GetUpperBound(1); b++)
{
Console.WriteLine("Enter your Surname :");
n[a, b] = Console.ReadLine();

Console.WriteLine("Enter your GWA :");
gwa[a, b] = Convert.ToInt32(Console.ReadLine());
Console.WriteLine();
}
}

Console.WriteLine();

Array.Sort(gwa);
for (int a = 0; a < n.GetUpperBound(1); a++)
{
for (int b = 0; b < n.GetUpperBound(1); b++)
{
Console.WriteLine("Your Surname is " + n[a, b] + " and your GWA is " + gwa[a, b]);
}
}
}
}
}

ang problem po dito ay yung Array.Sort, see attach file po sir, ayan po ang problem.
 

Attachments

Similar threads

Back
Top