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

Chapter1/homework/1and2 #806

Open
wants to merge 26 commits into
base: Chapter1/Homework/1And2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
f7bd67e
Update README.md
Almantask Jan 8, 2020
83f8214
Update README.md
Almantask Jan 10, 2020
853adf9
Update README.md
Almantask Jan 10, 2020
be8c7cf
Update README.md
Almantask Jan 10, 2020
fc060b9
Update README.md
Almantask Jan 10, 2020
aac4798
Update README.md
Almantask Jan 10, 2020
22ee3c7
Update README.md
Almantask Jan 12, 2020
ee020f7
Edit gitginore to exclude .idea/
Stallind Jan 15, 2020
c5458a3
Merge pull request #5 from Stallind/master
Almantask Jan 19, 2020
6559c44
some changes to improve the readmae
Feb 15, 2020
ee4ba56
Merge pull request #172 from RoelofWobben/master
Almantask Feb 17, 2020
91dd9ff
Proper title added
Almantask Feb 23, 2020
e9302fc
Updated readme by moving all the details to new joiner guide
Almantask Apr 2, 2020
2a5ed2c
Better intro to new joiners
Almantask Apr 2, 2020
24d5a43
Better formatting
Almantask Apr 2, 2020
0ffed9e
Added boot camp logo
Almantask Apr 2, 2020
c06de6e
Added boot camp banner
Almantask Apr 2, 2020
26ff3c0
Merge branch 'master' of https://github.com/csinn/CSharp-From-Zero-To…
Almantask Apr 2, 2020
2112eb6
Updated banner image
Almantask Apr 2, 2020
748b803
Update README.md
Almantask Apr 28, 2020
78bf6bc
ignore VS Code settings folder
mihailfox Apr 29, 2020
f3fca8a
Merge pull request #353 from mihailfox/add-vscode-settings-folder-to-…
Almantask May 1, 2020
ddd0819
Homework1And2/Divan.
7IronSnow7 Sep 23, 2023
7c089fd
Resolved merge conflict in README.md
7IronSnow7 Sep 23, 2023
4b2d0c5
Homework1And2/Divan.
7IronSnow7 Sep 23, 2023
d2ae9ce
Homework1And2/Divan.
7IronSnow7 Sep 23, 2023
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
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ bld/

# Visual Studio 2015/2017 cache/options directory
.vs/

#Jetbrain rider
.idea/

# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/

Expand Down Expand Up @@ -348,3 +352,6 @@ MigrationBackup/

# Ionide (cross platform F# VS Code tools) working folder
.ionide/

# VS Code settings folder
.vscode/
11 changes: 9 additions & 2 deletions Bootcamp.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29519.87
# Visual Studio Version 17
VisualStudioVersion = 17.4.33213.308
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Src", "Src", "{3E67C921-D341-42FB-9934-B03C05A28BEB}"
EndProject
Expand All @@ -11,6 +11,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BootCamp.Chapter", "Src\Boo
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BootCamp.Chapter.Tests", "Tests\BootCamp.Chapter.Tests\BootCamp.Chapter.Tests.csproj", "{955C76C7-582C-4C12-A253-0551A59E630A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Homework1", "Homework1\Homework1.csproj", "{C6C3790D-483C-4FD0-88D2-E35A033EE5C2}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -25,13 +27,18 @@ Global
{955C76C7-582C-4C12-A253-0551A59E630A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{955C76C7-582C-4C12-A253-0551A59E630A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{955C76C7-582C-4C12-A253-0551A59E630A}.Release|Any CPU.Build.0 = Release|Any CPU
{C6C3790D-483C-4FD0-88D2-E35A033EE5C2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C6C3790D-483C-4FD0-88D2-E35A033EE5C2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C6C3790D-483C-4FD0-88D2-E35A033EE5C2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C6C3790D-483C-4FD0-88D2-E35A033EE5C2}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{AD4B9DF0-A466-44FE-ADB8-D16BE20E6A37} = {3E67C921-D341-42FB-9934-B03C05A28BEB}
{955C76C7-582C-4C12-A253-0551A59E630A} = {7559227A-AC63-40F9-B43A-BF1D3CB352D6}
{C6C3790D-483C-4FD0-88D2-E35A033EE5C2} = {3E67C921-D341-42FB-9934-B03C05A28BEB}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {5969FA83-B2F9-4714-8336-EEBBDA71F6FF}
Expand Down
10 changes: 10 additions & 0 deletions Homework1/Homework1.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>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
29 changes: 29 additions & 0 deletions Homework1/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
namespace Homework1
{
class Program
{
static void Main(string[] args)
{
// Person One
Console.WriteLine(PersonDetails("Tom", "Jefferson", 19, 50, 156.65));
Console.WriteLine($"BMI = {Math.Round(BodyMassIndex(50, 156.65), 1)}");
// Person Two
Console.WriteLine($"\n{PersonDetails("Tommy", "Shelby", 47, 70, 173.00)}");
Console.WriteLine($"BMI = {Math.Round(BodyMassIndex(70, 173.00), 1)}");
}
public static string PersonDetails(string firstName, string lastName, int age, int weight, double height)
{
var userDetails = string.Empty;

userDetails = $"{firstName} {lastName} is {age} years old, his weight is {weight} kg and his height is ";

return userDetails;
}
public static double BodyMassIndex(int weight, double height)
{
var bmi = weight / (Math.Pow((height / 100), 2));

return bmi;
}
}
}
97 changes: 1 addition & 96 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,97 +1,2 @@
# C#: From Zero To Hero
Chapter 1. Homework 1 and 2: Variables, Visual Studio, Git and Github

## Chapter 1. Homework 1 and 2: Variables, Visual Studio, Git and Github

### Intro

#### Variables

Nearly every single program needs variables.
A variable has a name, type and value. They are used to carry some small state (value) throug some part of the program.
The whole point of variables is to be consumed.
We consume variables by passing them into functions or doing arithmetic operations.

#### Finding missing pieces (Console)

Often, a lesson won't cover 100% of material needed for finishing homework. But this is a representation of real life, where you constantly have to get the missing pieces (most likely through googling). The missing pieces in this homework are:

``Console.ReadLine``
``int.Parse``
``double.Parse``.

#### Visual Studio

IDE is an environment where all the programming is done.
It offers all the needed tools:
- Hints while writing code (Intellisence)
- Run code
- Debug code
- Analyse code: see errors, warnings, code complexity...
Visual Studio is probably the best IDE for developing C# code, because it has everything you need out of the box.
Visual Studio Code is another IDE that we could use for C#, though it's much more general and you will need to configure it before you can use it.

#### Open source and Github

Open source code is how people all around the world, without knowing each, other collaborate.
Such way of collaborating needs to be learned early, if you want to do anything serious with programming.
It's not very easy and intutive to learn right away.
Regardless of that, it's necessary if we want to ensure easy and convenient collaboration.

Github is an open source code host. It's the most popular and widely use host for git.
Therefore we will be using it for all of our homework.

### Pull Request

Pull request allows requesting a change for an open source project.
It doesn't matter who asks to make a change, all that matters is that changes are relevant and adds value to the repository.

You will be learning all of the above throughout this homework.

### Task

#### Code

Read name, surename, age, weight (in kg) and height (in cm) **from console**. DO NOT HARDCODE (not int age = 5 etc).
1) Print all the info based on the example message below:

```Tom Jefferson is 19 years old, his weight is 50 kg and his height is 156.5 cm.```

2) Calculate and print body-mass index (BMI)
3) Do it for 2 people (repeat the same thing twice)

#### Github

Full guide of how to use Visual Studio teams can be found here: https://github.com/csinn/CSharp-From-Zero-To-Hero/wiki/Github-In-Vs

* Fork https://github.com/csinn/CSharp-From-Zero-To-Hero/tree/Chapter1/Homework/1And2
* Open the link.
* Click the fork button in the upper right.
* Click the green Clone or download button and clone your repository the way that suits you best.
* Open your repository in Visual Studio 2019.
* Select the right branch in the bottom right! That name should be Chapter1/Homework/1And2 instead of master in the end.
* Make sure that you open Bootcamp.sln. This is called a solution. Remember this!
* Source code from lesson 1 homework should end up on your forked branch.
* Open the Src folder.
* Open the BootCamp.Chapter project file. Remember that this is a project file!
* Open the Program.cs file.
* Put your code from homework 1 here.
* Create a pull request to request your forked branch to be merged to the source branch.
* Click the pencil symbol in the bottom right and type in a commit message.
* Press commit button.
* Click the single arrow button (next to the pencil) in the bottom right.
* Push your commit.
* Click the line plus arrow button (next to the single arrow) in the bottom right.
* Click create new element.
* Click on master branch and change it to Chapter1/Homework/1And2.
* Give your pull request a meaningful title and description.
* Click create.
* Pass all Pull Request checks (mentor review)

### Hints

* The tasks require you to have already created an account on GitHub. Do that first!
* If you do not understand something or need help:
* Ask questions in the channel bc-discussion in Discord.
* Check the wiki of this repository (work in progress!).
* Check the bc-materials channel for reference material.
* Check the bc-announcements channel for related stuff.
Binary file added Res/kaisi_banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 22 additions & 1 deletion Src/BootCamp.Chapter/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,30 @@ namespace BootCamp.Chapter
{
class Program
{
// Homework1 by Divan
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
// Person One
Console.WriteLine(PersonDetails("Tom", "Jefferson", 19, 50, 156.65));
Console.WriteLine($"BMI = {Math.Round(BodyMassIndex(50, 156.65), 1)}");
// Person Two
Console.WriteLine($"\n{PersonDetails("Tommy", "Shelby", 47, 70, 173.00)}");
Console.WriteLine($"BMI = {Math.Round(BodyMassIndex(70, 173.00), 1)}");
}
public static string PersonDetails(string firstName, string lastName, int age, int weight, double height)
{
var userDetails = string.Empty;

userDetails = $"{firstName} {lastName} is {age} years old, his weight is {weight} kg and his height is ";

return userDetails;
}
public static double BodyMassIndex(int weight, double height)
{
var bmi = weight / (Math.Pow((height / 100), 2));

return bmi;
}
}
}

Binary file added approval.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.