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

add a homework week Four #71

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"format": 1,
"restore": {
"C:\\Users\\v-ambintiabd\\source\\repos\\ConsoleApp9\\ConsoleApp9\\ConsoleApp9.csproj": {}
"C:\\MY_C-_Practise\\week2\\Amira\\ConsoleApp9\\ConsoleApp9\\ConsoleApp9.csproj": {}
},
"projects": {
"C:\\Users\\v-ambintiabd\\source\\repos\\ConsoleApp9\\ConsoleApp9\\ConsoleApp9.csproj": {
"C:\\MY_C-_Practise\\week2\\Amira\\ConsoleApp9\\ConsoleApp9\\ConsoleApp9.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "C:\\Users\\v-ambintiabd\\source\\repos\\ConsoleApp9\\ConsoleApp9\\ConsoleApp9.csproj",
"projectUniqueName": "C:\\MY_C-_Practise\\week2\\Amira\\ConsoleApp9\\ConsoleApp9\\ConsoleApp9.csproj",
"projectName": "ConsoleApp9",
"projectPath": "C:\\Users\\v-ambintiabd\\source\\repos\\ConsoleApp9\\ConsoleApp9\\ConsoleApp9.csproj",
"projectPath": "C:\\MY_C-_Practise\\week2\\Amira\\ConsoleApp9\\ConsoleApp9\\ConsoleApp9.csproj",
"packagesPath": "C:\\Users\\v-ambintiabd\\.nuget\\packages\\",
"outputPath": "C:\\Users\\v-ambintiabd\\source\\repos\\ConsoleApp9\\ConsoleApp9\\obj\\",
"outputPath": "C:\\MY_C-_Practise\\week2\\Amira\\ConsoleApp9\\ConsoleApp9\\obj\\",
"projectStyle": "PackageReference",
"fallbackFolders": [
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//------------------------------------------------------------------------------
// <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.
Expand All @@ -14,7 +13,7 @@
[assembly: System.Reflection.AssemblyCompanyAttribute("ConsoleApp9")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+ae9f08bd17cc7f36e53f766554fcf6c8845a029f")]
[assembly: System.Reflection.AssemblyProductAttribute("ConsoleApp9")]
[assembly: System.Reflection.AssemblyTitleAttribute("ConsoleApp9")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
e5861c3a45dfc8c9be4bad9ff9886eab01fadecc3d7959911da577577a9243c4
9ecd2b61c567d805eee4bcc7f7391479218e0444d5da3d933ee88689299d7813
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ build_property.PlatformNeutralAssembly =
build_property.EnforceExtendedAnalyzerRules =
build_property._SupportedPlatformList = Linux,macOS,Windows
build_property.RootNamespace = ConsoleApp9
build_property.ProjectDir = C:\Users\v-ambintiabd\source\repos\ConsoleApp9\ConsoleApp9\
build_property.ProjectDir = C:\MY_C-_Practise\week2\Amira\ConsoleApp9\ConsoleApp9\
build_property.EnableComHosting =
build_property.EnableGeneratedComInterfaceComImportInterop =
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,18 @@ C:\Users\v-ambintiabd\source\repos\ConsoleApp9\ConsoleApp9\obj\Debug\net8.0\refi
C:\Users\v-ambintiabd\source\repos\ConsoleApp9\ConsoleApp9\obj\Debug\net8.0\ConsoleApp9.pdb
C:\Users\v-ambintiabd\source\repos\ConsoleApp9\ConsoleApp9\obj\Debug\net8.0\ConsoleApp9.genruntimeconfig.cache
C:\Users\v-ambintiabd\source\repos\ConsoleApp9\ConsoleApp9\obj\Debug\net8.0\ref\ConsoleApp9.dll
C:\MY_C-_Practise\week2\Amira\ConsoleApp9\ConsoleApp9\bin\Debug\net8.0\ConsoleApp9.exe
C:\MY_C-_Practise\week2\Amira\ConsoleApp9\ConsoleApp9\bin\Debug\net8.0\ConsoleApp9.deps.json
C:\MY_C-_Practise\week2\Amira\ConsoleApp9\ConsoleApp9\bin\Debug\net8.0\ConsoleApp9.runtimeconfig.json
C:\MY_C-_Practise\week2\Amira\ConsoleApp9\ConsoleApp9\bin\Debug\net8.0\ConsoleApp9.dll
C:\MY_C-_Practise\week2\Amira\ConsoleApp9\ConsoleApp9\bin\Debug\net8.0\ConsoleApp9.pdb
C:\MY_C-_Practise\week2\Amira\ConsoleApp9\ConsoleApp9\obj\Debug\net8.0\ConsoleApp9.GeneratedMSBuildEditorConfig.editorconfig
C:\MY_C-_Practise\week2\Amira\ConsoleApp9\ConsoleApp9\obj\Debug\net8.0\ConsoleApp9.AssemblyInfoInputs.cache
C:\MY_C-_Practise\week2\Amira\ConsoleApp9\ConsoleApp9\obj\Debug\net8.0\ConsoleApp9.AssemblyInfo.cs
C:\MY_C-_Practise\week2\Amira\ConsoleApp9\ConsoleApp9\obj\Debug\net8.0\ConsoleApp9.csproj.CoreCompileInputs.cache
C:\MY_C-_Practise\week2\Amira\ConsoleApp9\ConsoleApp9\obj\Debug\net8.0\ConsoleApp9.sourcelink.json
C:\MY_C-_Practise\week2\Amira\ConsoleApp9\ConsoleApp9\obj\Debug\net8.0\ConsoleApp9.dll
C:\MY_C-_Practise\week2\Amira\ConsoleApp9\ConsoleApp9\obj\Debug\net8.0\refint\ConsoleApp9.dll
C:\MY_C-_Practise\week2\Amira\ConsoleApp9\ConsoleApp9\obj\Debug\net8.0\ConsoleApp9.pdb
C:\MY_C-_Practise\week2\Amira\ConsoleApp9\ConsoleApp9\obj\Debug\net8.0\ConsoleApp9.genruntimeconfig.cache
C:\MY_C-_Practise\week2\Amira\ConsoleApp9\ConsoleApp9\obj\Debug\net8.0\ref\ConsoleApp9.dll
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ffc1bf384d22c9caf40f42b256f2b83fe12ba8225ba859f7f851b6f72de0e169
534a79559179b9a8c61594eec013edec685c53f613c034668cd9f8ffd7851a23
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"documents":{"C:\\MY_C-_Practise\\*":"https://raw.githubusercontent.com/amira1234567890/MY_C-_Practise/ae9f08bd17cc7f36e53f766554fcf6c8845a029f/*"}}
Binary file modified week2/Amira/ConsoleApp9/ConsoleApp9/obj/Debug/net8.0/apphost.exe
Binary file not shown.
Binary file not shown.
Binary file not shown.
6 changes: 3 additions & 3 deletions week2/Amira/ConsoleApp9/ConsoleApp9/obj/project.assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
"project": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "C:\\Users\\v-ambintiabd\\source\\repos\\ConsoleApp9\\ConsoleApp9\\ConsoleApp9.csproj",
"projectUniqueName": "C:\\MY_C-_Practise\\week2\\Amira\\ConsoleApp9\\ConsoleApp9\\ConsoleApp9.csproj",
"projectName": "ConsoleApp9",
"projectPath": "C:\\Users\\v-ambintiabd\\source\\repos\\ConsoleApp9\\ConsoleApp9\\ConsoleApp9.csproj",
"projectPath": "C:\\MY_C-_Practise\\week2\\Amira\\ConsoleApp9\\ConsoleApp9\\ConsoleApp9.csproj",
"packagesPath": "C:\\Users\\v-ambintiabd\\.nuget\\packages\\",
"outputPath": "C:\\Users\\v-ambintiabd\\source\\repos\\ConsoleApp9\\ConsoleApp9\\obj\\",
"outputPath": "C:\\MY_C-_Practise\\week2\\Amira\\ConsoleApp9\\ConsoleApp9\\obj\\",
"projectStyle": "PackageReference",
"fallbackFolders": [
"C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages"
Expand Down
4 changes: 2 additions & 2 deletions week2/Amira/ConsoleApp9/ConsoleApp9/obj/project.nuget.cache
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"version": 2,
"dgSpecHash": "gHEt2J6Y/d0=",
"dgSpecHash": "HYlEEYaW2Sg=",
"success": true,
"projectFilePath": "C:\\Users\\v-ambintiabd\\source\\repos\\ConsoleApp9\\ConsoleApp9\\ConsoleApp9.csproj",
"projectFilePath": "C:\\MY_C-_Practise\\week2\\Amira\\ConsoleApp9\\ConsoleApp9\\ConsoleApp9.csproj",
"expectedPackageFiles": [],
"logs": []
}
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 added week4/Amira/Week4/.vs/Week4/v17/.futdcache.v2
Binary file not shown.
Binary file added week4/Amira/Week4/.vs/Week4/v17/.suo
Binary file not shown.
62 changes: 62 additions & 0 deletions week4/Amira/Week4/.vs/Week4/v17/DocumentLayout.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"Version": 1,
"WorkspaceRootPath": "C:\\Users\\v-ambintiabd\\source\\repos\\Week4\\",
"Documents": [
{
"AbsoluteMoniker": "D:0:0:{83619CC6-AB41-4DBC-8F23-D3232BF019CF}|Week4\\Week4.csproj|c:\\users\\v-ambintiabd\\source\\repos\\week4\\week4\\class1.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}",
"RelativeMoniker": "D:0:0:{83619CC6-AB41-4DBC-8F23-D3232BF019CF}|Week4\\Week4.csproj|solutionrelative:week4\\class1.cs||{A6C744A8-0E4A-4FC6-886A-064283054674}"
},
{
"AbsoluteMoniker": "D:0:0:{83619CC6-AB41-4DBC-8F23-D3232BF019CF}|Week4\\Week4.csproj|c:\\users\\v-ambintiabd\\source\\repos\\week4\\week4\\readme.md||{EFC0BB08-EA7D-40C6-A696-C870411A895B}",
"RelativeMoniker": "D:0:0:{83619CC6-AB41-4DBC-8F23-D3232BF019CF}|Week4\\Week4.csproj|solutionrelative:week4\\readme.md||{EFC0BB08-EA7D-40C6-A696-C870411A895B}"
}
],
"DocumentGroupContainers": [
{
"Orientation": 0,
"VerticalTabListWidth": 256,
"DocumentGroups": [
{
"DockedWidth": 200,
"SelectedChildIndex": 3,
"Children": [
{
"$type": "Document",
"DocumentIndex": 1,
"Title": "README.md",
"DocumentMoniker": "C:\\Users\\v-ambintiabd\\source\\repos\\Week4\\Week4\\README.md",
"RelativeDocumentMoniker": "Week4\\README.md",
"ToolTip": "C:\\Users\\v-ambintiabd\\source\\repos\\Week4\\Week4\\README.md",
"RelativeToolTip": "Week4\\README.md",
"ViewState": "AQIAAAAAAAAAAAAAAAAAAAwAAAAAAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.001818|",
"WhenOpened": "2024-09-02T06:35:38.638Z",
"EditorCaption": ""
},
{
"$type": "Bookmark",
"Name": "ST:128:0:{75188d03-9892-4ae2-abf1-207126247ce5}"
},
{
"$type": "Bookmark",
"Name": "ST:129:0:{75188d03-9892-4ae2-abf1-207126247ce5}"
},
{
"$type": "Document",
"DocumentIndex": 0,
"Title": "Class1.cs",
"DocumentMoniker": "C:\\Users\\v-ambintiabd\\source\\repos\\Week4\\Week4\\Class1.cs",
"RelativeDocumentMoniker": "Week4\\Class1.cs",
"ToolTip": "C:\\Users\\v-ambintiabd\\source\\repos\\Week4\\Week4\\Class1.cs",
"RelativeToolTip": "Week4\\Class1.cs",
"ViewState": "AQIAAAAAAAAAAAAAAAAAAAkAAAAmAAAA",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000738|",
"WhenOpened": "2024-08-30T09:15:47.525Z",
"EditorCaption": ""
}
]
}
]
}
]
}
25 changes: 25 additions & 0 deletions week4/Amira/Week4/Week4.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.10.35201.131
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Week4", "Week4\Week4.csproj", "{83619CC6-AB41-4DBC-8F23-D3232BF019CF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{83619CC6-AB41-4DBC-8F23-D3232BF019CF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{83619CC6-AB41-4DBC-8F23-D3232BF019CF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{83619CC6-AB41-4DBC-8F23-D3232BF019CF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{83619CC6-AB41-4DBC-8F23-D3232BF019CF}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F90DAA8C-CD1E-44C7-950E-A02E9BF49095}
EndGlobalSection
EndGlobal
109 changes: 109 additions & 0 deletions week4/Amira/Week4/Week4/Class1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

public class Student
{
public int StudentId { get; set; }
public string? Name { get; set; } = string.Empty;
LeafShi1 marked this conversation as resolved.
Show resolved Hide resolved
public int MathScore { get; set; }
public int EnglishScore { get; set; }
public int ProgrammingScore { get; set; }
public int TotalScore => MathScore + EnglishScore + ProgrammingScore;
public bool PassedAllSubjects => MathScore > 60 && EnglishScore > 60 && ProgrammingScore > 60;
}

public class FileReader
{
private readonly string _filePath;

public FileReader(string filePath)
{
_filePath = filePath;
}

public List<Student> GetStudents()
{
if (!File.Exists(_filePath))
{
Console.WriteLine("File not found.");
return new List<Student>();
}

var students = new List<Student>();

try
{
// Skip header line
foreach (var line in File.ReadLines(_filePath).Skip(1))
LeafShi1 marked this conversation as resolved.
Show resolved Hide resolved
{
var parts = line.Split(',');
if (parts.Length < 5 ||
!int.TryParse(parts[0], out var studentId) ||
!int.TryParse(parts[2], out var mathScore) ||
!int.TryParse(parts[3], out var englishScore) ||
!int.TryParse(parts[4], out var programmingScore))
{
Console.WriteLine($"Skipping invalid line: {line}");
continue;
}

students.Add(new Student
{
StudentId = studentId,
Name = parts[1],
MathScore = mathScore,
EnglishScore = englishScore,
ProgrammingScore = programmingScore
});
}
}
catch (IOException ex)
{
Console.WriteLine($"An IO error occurred: {ex.Message}");
}
catch (Exception ex)
{
Console.WriteLine($"An error occurred: {ex.Message}");
}

return students;
}
}

class Program
{
static void Main()
{
// Construct the relative path to the file
var relativePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..", "..", "..", "students_scores.csv");
var fullPath = Path.GetFullPath(relativePath);

Console.WriteLine($"Attempting to read file from: {fullPath}");

var fileReader = new FileReader(fullPath);
var students = fileReader.GetStudents();

// 1. Get all student total score;
Console.WriteLine("\nAll student total scores:");
foreach (var student in students)
{
Console.WriteLine($"{student.Name}: {student.TotalScore}");
}

// 2. Print student name If he passes(>60) all his subjects
Console.WriteLine("\nStudents who passed all subjects (>60):");
foreach (var student in students.Where(s => s.PassedAllSubjects))
{
Console.WriteLine(student.Name);
}

// 3. Print top 3 student order by total score
Console.WriteLine("\nTop 3 students by total score:");
foreach (var student in students.OrderByDescending(s => s.TotalScore).Take(3))
{
Console.WriteLine($"{student.Name}: {student.TotalScore}");
}
}
}
12 changes: 12 additions & 0 deletions week4/Amira/Week4/Week4/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# C# Training Homework week4
# Student Data

### Description
This project is part of my C# week4 training.
1, Get all student total score;
2, Print student name If he passes(>60) all his subjects
3, Print top 3 student order by total score

# Usage:
1. cd array
2. dotnet run
10 changes: 10 additions & 0 deletions week4/Amira/Week4/Week4/Week4.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

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

</Project>
23 changes: 23 additions & 0 deletions week4/Amira/Week4/Week4/bin/Debug/net8.0/Week4.deps.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v8.0",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v8.0": {
"Week4/1.0.0": {
"runtime": {
"Week4.dll": {}
}
}
}
},
"libraries": {
"Week4/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
}
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
12 changes: 12 additions & 0 deletions week4/Amira/Week4/Week4/bin/Debug/net8.0/Week4.runtimeconfig.json
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")]
23 changes: 23 additions & 0 deletions week4/Amira/Week4/Week4/obj/Debug/net8.0/Week4.AssemblyInfo.cs
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("Week4")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyProductAttribute("Week4")]
[assembly: System.Reflection.AssemblyTitleAttribute("Week4")]
[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 @@
43b12d54c694a5eec7e271d4486c0231a337be9c3809b364bb2ac96c3bf92bb8
Loading