-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
103 lines (93 loc) · 2.97 KB
/
Program.cs
File metadata and controls
103 lines (93 loc) · 2.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
using System;
namespace APSCalculator
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Welcome to the Admission Point Score Calculator!");
// Get subject scores and levels
int[] subjectScores = new int[6];
string[] subjectLevels = new string[6];
string[] subjectNames = new string[6];
for (int i = 0; i < 6; i++)
{
Console.WriteLine($"\nEnter details for Subject {i + 1}:");
Console.Write("Subject Name: ");
subjectNames[i] = Console.ReadLine();
int score;
while (true)
{
Console.Write("Subject Score (0-100): ");
if (int.TryParse(Console.ReadLine(), out score) && score >= 0 && score <= 100)
{
subjectScores[i] = score;
break;
}
else
{
Console.WriteLine("Invalid score. Please enter a number between 0 and 100.");
}
}
}
// Calculate APS
int aps = CalculateAPS(subjectScores, subjectLevels);
// Display the result
Console.WriteLine("\n--------------------");
Console.WriteLine("Subject Breakdown:");
for (int i = 0; i < 6; i++)
{
Console.WriteLine($"{subjectNames[i]}: Score = {subjectScores[i]}, Points = {GetLevelPoints(subjectScores[i])}");
}
Console.WriteLine("--------------------");
Console.WriteLine($"Your total Admission Point Score (APS) is: {aps}");
Console.WriteLine("\nPress any key to exit...");
Console.ReadKey();
}
static int CalculateAPS(int[] scores, string[] levels)
{
int totalPoints = 0;
for (int i = 0; i < scores.Length; i++)
{
totalPoints += GetLevelPoints(scores[i]);
}
return totalPoints;
}
static int GetLevelPoints(int score)
{
if (score >= 80)
{
return 7;
}
else if (score >= 70)
{
return 6;
}
else if (score >= 60)
{
return 5;
}
else if (score >= 50)
{
return 4;
}
else if (score >= 40)
{
return 3;
}
else if (score >= 30)
{
return 2;
}
else if (score >= 0 && score <= 100)
{
return 1;
}
else
{
Console.WriteLine($"Warning: Invalid score '{score}'. Points will be 0 for this subject.");
return 0;
}
}
}
}