Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Done Week 4 #67

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions week4/Faris/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Learned about :
- LINQ
- IEnumerate
- its method
- syntax
- query

Project :
1. Read csv file
2. Insert into a list
3. Print all students' scores
4. Print students who passed all subjects
5. Print top 3 highest students
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"Version": 1,
"WorkspaceRootPath": "C:\\Users\\v-mufauzi\\Desktop\\PROJECT C#\\FARIS_WEEK_4\\StudentScore\\",
"Documents": [
{
"AbsoluteMoniker": "D:0:0:{A9BCE621-7AC6-479C-A164-977DBFA42683}|StudentScore\\StudentScore.csproj|c:\\users\\v-mufauzi\\desktop\\project c#\\faris_week_4\\studentscore\\studentscore\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{A9BCE621-7AC6-479C-A164-977DBFA42683}|StudentScore\\StudentScore.csproj|solutionrelative:studentscore\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
}
],
"DocumentGroupContainers": [
{
"Orientation": 0,
"VerticalTabListWidth": 256,
"DocumentGroups": [
{
"DockedWidth": 200,
"SelectedChildIndex": 1,
"Children": [
{
"$type": "Bookmark",
"Name": "ST:128:0:{75188d03-9892-4ae2-abf1-207126247ce5}"
},
{
"$type": "Document",
"DocumentIndex": 0,
"Title": "Program.cs",
"DocumentMoniker": "C:\\Users\\v-mufauzi\\Desktop\\PROJECT C#\\FARIS_WEEK_4\\StudentScore\\StudentScore\\Program.cs",
"RelativeDocumentMoniker": "StudentScore\\Program.cs",
"ToolTip": "C:\\Users\\v-mufauzi\\Desktop\\PROJECT C#\\FARIS_WEEK_4\\StudentScore\\StudentScore\\Program.cs*",
"RelativeToolTip": "StudentScore\\Program.cs*",
"ViewState": "AgIAADMAAAAAAAAAAAAIwEUAAAAfAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2024-08-26T08:56:16.105Z",
"EditorCaption": ""
}
]
}
]
}
]
}
41 changes: 41 additions & 0 deletions week4/Faris/StudentScore/.vs/StudentScore/v17/DocumentLayout.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"Version": 1,
"WorkspaceRootPath": "C:\\Users\\v-mufauzi\\Desktop\\PROJECT C#\\FARIS_WEEK_4\\StudentScore\\",
"Documents": [
{
"AbsoluteMoniker": "D:0:0:{A9BCE621-7AC6-479C-A164-977DBFA42683}|StudentScore\\StudentScore.csproj|c:\\users\\v-mufauzi\\desktop\\project c#\\faris_week_4\\studentscore\\studentscore\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{A9BCE621-7AC6-479C-A164-977DBFA42683}|StudentScore\\StudentScore.csproj|solutionrelative:studentscore\\program.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
}
],
"DocumentGroupContainers": [
{
"Orientation": 0,
"VerticalTabListWidth": 256,
"DocumentGroups": [
{
"DockedWidth": 200,
"SelectedChildIndex": 1,
"Children": [
{
"$type": "Bookmark",
"Name": "ST:128:0:{75188d03-9892-4ae2-abf1-207126247ce5}"
},
{
"$type": "Document",
"DocumentIndex": 0,
"Title": "Program.cs",
"DocumentMoniker": "C:\\Users\\v-mufauzi\\Desktop\\PROJECT C#\\FARIS_WEEK_4\\StudentScore\\StudentScore\\Program.cs",
"RelativeDocumentMoniker": "StudentScore\\Program.cs",
"ToolTip": "C:\\Users\\v-mufauzi\\Desktop\\PROJECT C#\\FARIS_WEEK_4\\StudentScore\\StudentScore\\Program.cs",
"RelativeToolTip": "StudentScore\\Program.cs",
"ViewState": "AgIAAAAAAAAAAAAAAAAAAAoAAAAmAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2024-08-26T08:56:16.105Z",
"EditorCaption": ""
}
]
}
]
}
]
}
24 changes: 24 additions & 0 deletions week4/Faris/StudentScore/StudentScore.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# 17
VisualStudioVersion = 17.11.35208.52
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StudentScore", "StudentScore\StudentScore.csproj", "{A9BCE621-7AC6-479C-A164-977DBFA42683}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{A9BCE621-7AC6-479C-A164-977DBFA42683}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A9BCE621-7AC6-479C-A164-977DBFA42683}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A9BCE621-7AC6-479C-A164-977DBFA42683}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A9BCE621-7AC6-479C-A164-977DBFA42683}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {931D55F9-D310-4A79-A2DE-7D09C2ECE04A}
EndGlobalSection
EndGlobal
79 changes: 79 additions & 0 deletions week4/Faris/StudentScore/StudentScore/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;

public class Student
{
public int StudentId { get; set; }
public string Name { get; set; }
public int MathScore { get; set; }
public int EnglishScore { get; set; }
public int ProgrammingScore { get; set; }
public int TotalScore => MathScore + EnglishScore + ProgrammingScore; //add all scores

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally we add a comment above the target code, and need a space between // and string.

}

public class Program
{
public static void Main()
{
var students = new List<Student>(); //declare student list

using (var StudentData = new StreamReader("Student.csv")) //read csv file

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to create different files for different classes, and define separate functions, then call these function from main.

{
var header = StudentData.ReadLine();
if (header == null) //check if
{
return;
}

string row;
while ((row = StudentData.ReadLine()) != null) //insert each row into string
{
var values = row.Split(',');

if (values.Length != 5) continue; //make sure it reads each column

if (int.TryParse(values[0], out int studentId) && //save into integer data type
int.TryParse(values[2], out int mathScore) &&
int.TryParse(values[3], out int englishScore) &&
int.TryParse(values[4], out int programmingScore))
{
students.Add(new Student //add to list
{
StudentId = studentId,
Name = values[1],
MathScore = mathScore,
EnglishScore = englishScore,
ProgrammingScore = programmingScore
});
}
}
}

Console.WriteLine("TOTAL SCORE OF ALL STUDENTS");
Console.WriteLine($"\n{"STUDENT ID",2} {"NAME",-12} {"TOTAL SCORES",-10}");
Console.WriteLine("----------------------------------------");
foreach (var student in students) //print all students scores
{
Console.WriteLine($"{student.StudentId,-10} {student.Name,-12} {student.TotalScore,-5}");
}

Console.WriteLine("\n\nSTUDENTS PASSED ALL SUBJECTS"); //list students pass all subjects
var passingStudents = students.Where(s => s.MathScore > 60 && s.EnglishScore > 60 && s.ProgrammingScore > 60);
foreach (var student in passingStudents)
{
Console.WriteLine(student.Name);
}

Console.WriteLine("\n\nTOP 3 HIGHEST SCORE STUDENTS"); //list 3 top students
Console.WriteLine($"\n{"STUDENT ID",2} {"NAME",-12} {"TOTAL SCORES",-10}");
Console.WriteLine("----------------------------------------");
var topStudents = students.OrderByDescending(s => s.TotalScore).Take(3);
foreach (var student in topStudents)
{
Console.WriteLine($"{student.StudentId,-10} {student.Name,-12} {student.TotalScore,-5}");
}
}
}
11 changes: 11 additions & 0 deletions week4/Faris/StudentScore/StudentScore/Student.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
StudentId,Name,MathScore,EnglishScore,ProgrammingScore
6142,Alice,70,91,53
3307,Bob,60,21,95
2365,Charlie,32,93,86
9153,David,63,68,45
5832,Eve,47,82,80
9874,Frank,96,91,83
7352,Grace,67,44,98
9320,Hank,58,61,38
8723,Ivy,94,81,92
6432,Jack,53,93,83
20 changes: 20 additions & 0 deletions week4/Faris/StudentScore/StudentScore/StudentScore.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CsvHelper" Version="33.0.1" />
</ItemGroup>

<ItemGroup>
<None Update="Student.csv">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
Binary file not shown.
11 changes: 11 additions & 0 deletions week4/Faris/StudentScore/StudentScore/bin/Debug/net8.0/Student.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
StudentId,Name,MathScore,EnglishScore,ProgrammingScore
6142,Alice,70,91,53
3307,Bob,60,21,95
2365,Charlie,32,93,86
9153,David,63,68,45
5832,Eve,47,82,80
9874,Frank,96,91,83
7352,Grace,67,44,98
9320,Hank,58,61,38
8723,Ivy,94,81,92
6432,Jack,53,93,83
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v8.0",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v8.0": {
"StudentScore/1.0.0": {
"dependencies": {
"CsvHelper": "33.0.1"
},
"runtime": {
"StudentScore.dll": {}
}
},
"CsvHelper/33.0.1": {
"runtime": {
"lib/net8.0/CsvHelper.dll": {
"assemblyVersion": "33.0.0.0",
"fileVersion": "33.0.1.24"
}
}
}
}
},
"libraries": {
"StudentScore/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
},
"CsvHelper/33.0.1": {
"type": "package",
"serviceable": true,
"sha512": "sha512-fev4lynklAU2A9GVMLtwarkwaanjSYB4wUqO2nOJX5hnzObORzUqVLe+bDYCUyIIRQM4o5Bsq3CcyJR89iMmEQ==",
"path": "csvhelper/33.0.1",
"hashPath": "csvhelper.33.0.1.nupkg.sha512"
}
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"runtimeOptions": {
"tfm": "net8.0",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "8.0.0"
},
"configProperties": {
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v8.0", FrameworkDisplayName = ".NET 8.0")]
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

using System;
using System.Reflection;

[assembly: System.Reflection.AssemblyCompanyAttribute("StudentScore")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyProductAttribute("StudentScore")]
[assembly: System.Reflection.AssemblyTitleAttribute("StudentScore")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

// Generated by the MSBuild WriteCodeFragment class.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dc1eae7bce7d0b119dbc06ccf4426c104a8aaf382219852f64ea652f455cc38c
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
is_global = true
build_property.TargetFramework = net8.0
build_property.TargetPlatformMinVersion =
build_property.UsingMicrosoftNETSdkWeb =
build_property.ProjectTypeGuids =
build_property.InvariantGlobalization =
build_property.PlatformNeutralAssembly =
build_property.EnforceExtendedAnalyzerRules =
build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = StudentScore
build_property.ProjectDir = C:\Users\v-mufauzi\Desktop\PROJECT C#\FARIS_WEEK_4\StudentScore\StudentScore\
build_property.EnableComHosting =
build_property.EnableGeneratedComInterfaceComImportInterop =
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// <auto-generated/>
global using global::System;
global using global::System.Collections.Generic;
global using global::System.IO;
global using global::System.Linq;
global using global::System.Net.Http;
global using global::System.Threading;
global using global::System.Threading.Tasks;
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
b564a710358a3331bd857f8f1dce4e9534355522771aac50fe8daa2967ef7e64
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
C:\Users\v-mufauzi\Desktop\PROJECT C#\FARIS_WEEK_4\StudentScore\StudentScore\bin\Debug\net8.0\StudentScore.exe
C:\Users\v-mufauzi\Desktop\PROJECT C#\FARIS_WEEK_4\StudentScore\StudentScore\bin\Debug\net8.0\StudentScore.deps.json
C:\Users\v-mufauzi\Desktop\PROJECT C#\FARIS_WEEK_4\StudentScore\StudentScore\bin\Debug\net8.0\StudentScore.runtimeconfig.json
C:\Users\v-mufauzi\Desktop\PROJECT C#\FARIS_WEEK_4\StudentScore\StudentScore\bin\Debug\net8.0\StudentScore.dll
C:\Users\v-mufauzi\Desktop\PROJECT C#\FARIS_WEEK_4\StudentScore\StudentScore\bin\Debug\net8.0\StudentScore.pdb
C:\Users\v-mufauzi\Desktop\PROJECT C#\FARIS_WEEK_4\StudentScore\StudentScore\bin\Debug\net8.0\CsvHelper.dll
C:\Users\v-mufauzi\Desktop\PROJECT C#\FARIS_WEEK_4\StudentScore\StudentScore\obj\Debug\net8.0\StudentScore.csproj.AssemblyReference.cache
C:\Users\v-mufauzi\Desktop\PROJECT C#\FARIS_WEEK_4\StudentScore\StudentScore\obj\Debug\net8.0\StudentScore.GeneratedMSBuildEditorConfig.editorconfig
C:\Users\v-mufauzi\Desktop\PROJECT C#\FARIS_WEEK_4\StudentScore\StudentScore\obj\Debug\net8.0\StudentScore.AssemblyInfoInputs.cache
C:\Users\v-mufauzi\Desktop\PROJECT C#\FARIS_WEEK_4\StudentScore\StudentScore\obj\Debug\net8.0\StudentScore.AssemblyInfo.cs
C:\Users\v-mufauzi\Desktop\PROJECT C#\FARIS_WEEK_4\StudentScore\StudentScore\obj\Debug\net8.0\StudentScore.csproj.CoreCompileInputs.cache
C:\Users\v-mufauzi\Desktop\PROJECT C#\FARIS_WEEK_4\StudentScore\StudentScore\obj\Debug\net8.0\StudentS.6C075980.Up2Date
C:\Users\v-mufauzi\Desktop\PROJECT C#\FARIS_WEEK_4\StudentScore\StudentScore\obj\Debug\net8.0\StudentScore.dll
C:\Users\v-mufauzi\Desktop\PROJECT C#\FARIS_WEEK_4\StudentScore\StudentScore\obj\Debug\net8.0\refint\StudentScore.dll
C:\Users\v-mufauzi\Desktop\PROJECT C#\FARIS_WEEK_4\StudentScore\StudentScore\obj\Debug\net8.0\StudentScore.pdb
C:\Users\v-mufauzi\Desktop\PROJECT C#\FARIS_WEEK_4\StudentScore\StudentScore\obj\Debug\net8.0\StudentScore.genruntimeconfig.cache
C:\Users\v-mufauzi\Desktop\PROJECT C#\FARIS_WEEK_4\StudentScore\StudentScore\obj\Debug\net8.0\ref\StudentScore.dll
C:\Users\v-mufauzi\Desktop\PROJECT C#\FARIS_WEEK_4\StudentScore\StudentScore\bin\Debug\net8.0\Student.csv
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3be10463e3f0d810845e9f50c4d23a937587597cb9aaeec846b6f59d046cc784
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading