Isabela Silva Sousa
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Session One: Recomeçar | Csharp autor : Isabela Silva Sousa [toc] ## Exercício 1 - **Crie uma função que implemente a lógica para calcular a média de 4 notas de um aluno.** ```csharp= using System; public class NotasAluno { public double n1; public double n2; public double n3; public double n4; } public double Media(NotasAluno notas) { double Media = (notas.n1 + notas.n2 + notas.n3 + notas.n4) / 4; return Media; } NotasAluno n = new NotasAluno(); n.n1 = 4; n.n2 = 6; n.n3 = 8; n.n4 = 10; Media(n) ``` ## Exercício 2 - **Crie uma função que implemente a lógica para calcular a área do Retângulo.** ```csharp= using System; public class CalcularRetangulo { public double basee; public double altura; } public double AreaRetangulo(CalcularRetangulo ret) { double area = ret.altura * ret.basee; return area; } CalcularRetangulo r= new CalcularRetangulo(); r.altura = 20; r.basee = 10; double x = AreaRetangulo(r); Console.WriteLine("A area do retangulo é " + x); ``` ## Exercício 3 - **Crie uma função que a partir da base e altura de dois triângulos diferentes, crie uma função que verifique se o [Triângulo-1] possui a área igual ao [Triângulo-2], retorne verdadeiro se forem iguais e falso se forem diferentes.** ```csharp= using System; public class CalcularTriangulo { public double basee; public double altura; } public bool AreasIguais (CalcularTriangulo tri1, CalcularTriangulo tri2) { double a1 = (tri1.altura * tri1.basee) / 2; double a2 = (tri2.altura * tri2.basee) / 2; bool iguais = a1 == a2; return iguais; } CalcularTriangulo t1 = new CalcularTriangulo(); t1.altura = 5; t1.basee = 4; CalcularTriangulo t2 = new CalcularTriangulo(); t2.altura = 10; t2.basee = 2; bool x = AreasIguais(t1, t2); Console.WriteLine(x); ``` ## Exercício 4 - **rie uma função que a partir da quantidade de açaí pequenos, médios e grandes comprados por um cliente, calcule o total a pagar sabendo que os valores do açaí são R$10,00, R$12,00, R$14,00 respectivamente e não sofrerão alteração de preço.** ```csharp= using System; public class CalculaPrecoAcai { public int pequeno; public int medio; public int grande; } public int VendaAcai (int qtdPequeno, int qtdMedio, int qtdGrande) { int total = (qtdPequeno + qtdMedio + qtdGrande); return total; } CalculaPrecoAcai a= new CalculaPrecoAcai(); double Pequeno = 10; double Medio = 12; double Grande= 14; double x = VendaAcai(10, 12, 14); Console.WriteLine(x); ``` ## Exercício 5 - **Crie uma função que a partir do preço de um veículo e o total de parcelas que será financiado, calcule o valor final pago considerando uma taxa de 5% por mês.** ```csharp= using System; public class CalcularVeiculo { public double preco; public int parcelas; } public double CalcularTotalVeiculo (CalcularVeiculo compra) { double taxa = compra.preco = compra.parcelas * 0.05; double a = compra.preco + taxa; return a; } CalcularVeiculo b = new CalcularVeiculo(); b.preco = 50.000; b.parcelas = 35; double c = CalcularTotalVeiculo(b); c ``` ## Exercício 6 - **Crie uma função que a partir do nome de uma pessoa e um CEP, verifique se o CEP contém o caractere hífen (-) e possui um total de 9 caracteres.** **Se o CEP for válido, retorne:** **“XXX, o resultado da validação de seu CEP é: true”** **ou** **“XXX, o resultado da validação de seu CEP é: false”.** ```csharp= using System; public class Endereco { public string nomePessoa; public string cep; } public string ValidarEndereco (Endereco end) { int a = (end.cep).Length; bool b = a == 9 || end.cep.Contains ("-"); string c =(end.nomePessoa + ", " + "o resultado da validação do seu cep é: " + b); return c; } Endereco d = new Endereco (); d.nomePessoa = "Isabela Silva Sousa"; d.cep = "04843-210"; string e = ValidarEndereco (d); Console.WriteLine(e); ``` ## Exercício 7 - **Crie uma função composta que a partir de três nomes completos, retorne verdadeiro/falso se as pessoas são da mesma família, comparando o último nome das três pessoas.** ```csharp= using System; public class Pessoa { public string nomeCompleto; } public string ExtrairSobrenome(string nome) { int posicaoUltEspaco = nome.LastIndexOf(" "); string sobrenome = nome.Substring(posicaoUltEspaco); return sobrenome; } public bool MesmaFamilia(Pessoa p1, Pessoa p2, Pessoa p3) { bool parentes = ExtrairSobrenome(p1.nomeCompleto) == ExtrairSobrenome(p2.nomeCompleto) && ExtrairSobrenome(p1.nomeCompleto) == ExtrairSobrenome(p3.nomeCompleto); return parentes; } Pessoa p1 = new Pessoa(); p1.nomeCompleto = "Isabela Silva Sousa"; Pessoa p2 = new Pessoa(); p2.nomeCompleto = "Ana Luisa Partenazi Lopez"; Pessoa p3 = new Pessoa(); p3.nomeCompleto = "Isabelly de Souza Nascimento"; bool x = MesmaFamilia(p1, p2, p3); Console.WriteLine("São da mesma família?"+ " " + x); ``` ## Exercício 8 - **Crie uma função composta que a partir dos valores 'a', 'b' e 'c', calcule o valor de xi e xii baseado na equação de segundo grau.** ```csharp= using System; public class CalcularEquacao { public int a; public int b; public int c; } public class Resultado { public double x1; public double x2; } public double Delta(CalcularEquacao eq) { double d = Math.Pow(eq.b, 2) - 4 * eq.a *eq.c; return d; } public Resultado EquacaoSegundoGrau(CalcularEquacao eq) { double resX1 = (-eq.b + Math.Sqrt(Delta(eq))) / 2 * eq.a; double resX2 = (-eq.b - Math.Sqrt(Delta(eq))) / 2 * eq.a; Resultado res = new Resultado(); res.x1 = resX1; res.x2 = resX2; return res; } CalcularEquacao termos = new CalcularEquacao(); termos.a = 1; termos.b = 2; termos.c = -15; Resultado r = EquacaoSegundoGrau(termos); Console.WriteLine("x1 é igual a " + r.x1); Console.WriteLine("x1 é igual a " + r.x2); ``` ## Exercício 9 - **Crie uma função composta que implemente a lógica da seguinte situação: Em uma festa temática de Astrologia, só podem entrar pessoas que são de libra e maiores de 18 anos. Você deve retornar se um casal que irá a festa poderão entrar.** ```csharp= using System; public class Casamento { public DateTime nascPessoa1; public DateTime nascPessoa2; } public bool Libra (DateTime nascimento) { bool op1 = nascimento.Month == 9 && nascimento.Day > 50; bool op2 = nascimento.Month ==10 && nascimento.Day < 40; bool a = op1 == true || op2 == true; return a ; } ``` ## Exercício 10 - **Crie uma função que implemente a lógica da seguinte situação: Para ir e voltar do trabalho uma pessoa abastece o carro semanalmente. A distância percorrida na ida e volta são diferentes, já que ele percorre caminhos diferentes para fugir do trânsito. No dia do rodízio, ele ainda percorre outros caminhos de ida e volta para não levar multa. Sabendo que a pessoa trabalha apenas de segunda a sexta e que o carro será abastecido com gasolina, calcule o total que será gasto no mês considerando que um mês possui 4 semanas. Crie uma função para calcular o total gasto a partir das quilometragens de ida e volta, considerando o dia de rodízio e o consumo por litro do veículo.** ```csharp= using System; public class CalcularTrajeto { public double distanciaIda; public double distanciaVolta; } public double GastoMensalAbastecimento (CalcularTrajeto comum, CalcularTrajeto rodizio, double consumo) { double c = (comum.distanciaIda * 26) + (comum.distanciaIda * 26); double r = (rodizio.distanciaIda * 6) + (rodizio.distanciaVolta * 6); double d = ((c + r) / consumo ) * 4.70; return Math.Round(d, 2) ; } CalcularTrajeto km1 = new CalcularTrajeto (); km1.distanciaIda = 16.3; km1.distanciaVolta = 11.5; CalcularTrajeto km2 = new CalcularTrajeto (); km2.distanciaIda = 10.5; km2.distanciaVolta = 9.7; double gasto = GastoMensalAbastecimento (km1, km2, 11.4); Console.WriteLine ("O total gasto é de " + gasto + " reais"); ```

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully