Skip to content
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
10 changes: 10 additions & 0 deletions ConsoleApp1/ConsoleApp1.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>
14 changes: 14 additions & 0 deletions ConsoleApp1/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// See https://aka.ms/new-console-template for more information
using ConsoleApp1;



/*********/
Console.WriteLine("Hi!");
Console.Write("Please Enter your Name:");
var nameinput = Console.ReadLine();
Console.Write("Please Enter your Age:");
int ageinput = Convert.ToInt32(Console.ReadLine());
Student student = new Student(nameinput,ageinput);
Console.WriteLine(student.Introduce());
/*********/
30 changes: 30 additions & 0 deletions ConsoleApp1/Student.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
internal class Student
{
public Student()
{ }

public Student(string name, int age)
{
Age = age;
Name = name;
}

private string name;
private int age;
public int Age { get { return age; } set { age = value; } }
public string Name { get { return name; } set { name = value; } }

public string Introduce()
{
return $"Hello, my name is {Name} and I am {Age} years old.";
}
}
}
75 changes: 75 additions & 0 deletions ConsoleApp2/BankAccount.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{
internal class BankAccount
{
public BankAccount() { }

public BankAccount(int init)
{
Balance = init;
}

private int balance = 0;

public int Balance
{
get { return balance; }
set
{
balance = value;
}
}

public bool Deposit(double myvalue)
{
bool result = false;

if (myvalue < 0)
{
return false;
}

if (balance + myvalue > int.MaxValue)
{
return false;
}

balance += (int)myvalue;
return true;
}

public bool WithDraw(double amount)
{
if (amount <= 0)
{
return false;
}

if (balance < 0)
{
return false;
}

if (balance < amount)
{
return false;
}

balance -= (int)amount;
return true;

}

public int GetBalance()
{
return balance;
}

}
}
10 changes: 10 additions & 0 deletions ConsoleApp2/ConsoleApp2.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>
12 changes: 12 additions & 0 deletions ConsoleApp2/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// See https://aka.ms/new-console-template for more information

/*********/
using ConsoleApp2;
Console.WriteLine("Enter init Balance value:");
int val = Convert.ToInt32(Console.ReadLine());

BankAccount ba = new BankAccount(val);
Console.WriteLine("=============");
Console.WriteLine($"your Bank amount is : {ba.GetBalance()}");
Console.WriteLine("=============");
/*********/
10 changes: 10 additions & 0 deletions ConsoleApp3/ConsoleApp3.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>
22 changes: 22 additions & 0 deletions ConsoleApp3/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// See https://aka.ms/new-console-template for more information

using ConsoleApp3;

int a ;
Console.Write("Enter a:");
a = Convert.ToInt32(Console.ReadLine());
int b;
Console.Write("Enter b:");
b = Convert.ToInt32(Console.ReadLine());
int c;
Console.WriteLine($"value a is: {a}");
Console.WriteLine($"value b is: {b}");
Statistics stats = new Statistics();
stats.AnalyzeNumbers(a, ref b, out c);
Console.WriteLine($"After Claculate");
Console.WriteLine($"value a was: {a}");
Console.WriteLine($"value b is: {b}");
Console.WriteLine($"value c is: {c}");



18 changes: 18 additions & 0 deletions ConsoleApp3/Statistics.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp3
{
internal class Statistics
{
public string AnalyzeNumbers(int a, ref int b, out int c)
{
c = a + b;
b = b * 2;
return a.ToString();
}
}
}
32 changes: 32 additions & 0 deletions ConsoleApp4/ArrayAnalyzer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp4
{
public class ArrayAnalyzer
{
public void AnalyzeArray(int[] array, ref int max, out double average)
{
if (array == null || array.Length == 0)
{
max = 0;
average = 0.0;
return;
}
max = array[0];
int sum = 0;
for (int i = 0; i < array.Length; i++)
{
if (array[i] > max)
{
max = array[i];
}
sum += array[i];
}
average = (double)sum / array.Length;
}
}
}
10 changes: 10 additions & 0 deletions ConsoleApp4/ConsoleApp4.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>
32 changes: 32 additions & 0 deletions ConsoleApp4/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using ConsoleApp4;

ArrayAnalyzer analyzer = new ArrayAnalyzer();
Console.Write("اندازه آرایه را وارد کنید: ");
int size = Convert.ToInt32(Console.ReadLine());
int[] numbers = new int[size];
if (size == 0)
{
Console.WriteLine("آرایه خالی است.");
}
else
{
Console.Write($"اندازه آرایه شما: {size}");
}
for (int i = 0; i < size; i++)
{
Console.Write($"عنصر {i + 1} را وارد کنید: ");
while (!int.TryParse(Console.ReadLine(), out numbers[i]))
{
Console.Write($"لطفاً یک عدد صحیح برای عنصر {i + 1} وارد کنید: ");
}
}

int maxValue = 0;
double averageValue;
analyzer.AnalyzeArray(numbers, ref maxValue, out averageValue);
Console.WriteLine("نتایج :");

Console.WriteLine($"بزرگترین عدد: {maxValue}");
Console.WriteLine($"میانگین اعداد: {averageValue}");

Console.ReadLine();
43 changes: 43 additions & 0 deletions HomeWork2-InitialFirstConsoleAppPart2-main.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.10.36602.27
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp1", "ConsoleApp1\ConsoleApp1.csproj", "{8BA57592-F765-45F5-A6BC-971EF8F7593F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp2", "ConsoleApp2\ConsoleApp2.csproj", "{D02EB025-25FB-4E83-8F18-9EA61F4BC339}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp3", "ConsoleApp3\ConsoleApp3.csproj", "{6093F595-2EA3-4A9D-9C92-97FBA486F1F3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp4", "ConsoleApp4\ConsoleApp4.csproj", "{B36027EB-08E2-4C78-B81D-4BE29305C696}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{8BA57592-F765-45F5-A6BC-971EF8F7593F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8BA57592-F765-45F5-A6BC-971EF8F7593F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8BA57592-F765-45F5-A6BC-971EF8F7593F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8BA57592-F765-45F5-A6BC-971EF8F7593F}.Release|Any CPU.Build.0 = Release|Any CPU
{D02EB025-25FB-4E83-8F18-9EA61F4BC339}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D02EB025-25FB-4E83-8F18-9EA61F4BC339}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D02EB025-25FB-4E83-8F18-9EA61F4BC339}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D02EB025-25FB-4E83-8F18-9EA61F4BC339}.Release|Any CPU.Build.0 = Release|Any CPU
{6093F595-2EA3-4A9D-9C92-97FBA486F1F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6093F595-2EA3-4A9D-9C92-97FBA486F1F3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6093F595-2EA3-4A9D-9C92-97FBA486F1F3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6093F595-2EA3-4A9D-9C92-97FBA486F1F3}.Release|Any CPU.Build.0 = Release|Any CPU
{B36027EB-08E2-4C78-B81D-4BE29305C696}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B36027EB-08E2-4C78-B81D-4BE29305C696}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B36027EB-08E2-4C78-B81D-4BE29305C696}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B36027EB-08E2-4C78-B81D-4BE29305C696}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F82C14CC-D0B5-4CA1-A440-D183D571016D}
EndGlobalSection
EndGlobal