so, long story short i want to take the absent person and import only that one person to the absent list, every time i tried this it imported everyone from the students list so that isnt much help;
this is so at the very end i can clear and display every student with the respective colors for their attendance, if theyre absent they're red, and if they were present they are green
ty in advance :)
using System.Collections.Generic;
namespace HelloWorld
{
class Hello
{
static void Main(string[] args)
{
List<string> students = new List<string>(5);
students.Add("Obama Ojane");
students.Add("Yarik Ze");
students.Add("Allen O'neill");
students.Add("Naveen Sharma");
students.Add("Monica Rathbun");
students.Add("David McCarter");
students.Add("Zayne Pan");
students.Add("Rah");
int v = 0;
int abs = 0;
int pres = 0;
List<string> absent = new List<string>(5);
List<string> present = new List<string>(5);
foreach (string a in students)
{
Console.Write(students[v] + ": ");
string attendance = Console.ReadLine();
if (attendance == "absent" || attendance == "abs" || attendance == "a")
{
abs++;
absent.Append(attendance);
String studentNameA = students[v];
absent.Add(studentNameA);
}
if (attendance == "present" || attendance == "pres" || attendance == "p")
{
pres++;
present.Append(attendance);
String studentNameP = students[v];
absent.Add(studentNameP);
}
v++;
}
Console.WriteLine();
Console.Clear();
Console.WriteLine("total present: " + pres);
Console.WriteLine("total absent: " + abs);
Console.WriteLine("total students: " + (abs+pres));
Console.ForegroundColor = ConsoleColor.Red;
for (int i = 0; i < absent.Count; i++)
{
Console.WriteLine(absent[i]);
}
Console.ForegroundColor = ConsoleColor.Green;
for (int i = 0; i < present.Count; i++)
{
Console.WriteLine(present[i]);
}
}
}
}
from Recent Questions - Stack Overflow https://ift.tt/3Ia27f5
https://ift.tt/eA8V8J
No comments:
Post a Comment