Letícia Santos Rocha
    • 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
    • Make a copy
    • 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 Make a copy 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
    # TIME TO BECOME A NINJA| C# autora: Letícia Rocha✨💖💖 [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; // Função Notas Aluno double Notas(double nota1, double nota2, double nota3, double nota4) { double Nota1= (nota1); double Nota2= (nota2); double Nota3= (nota3); double Nota4 = (nota4); double Nota5 = (nota4 + nota1 + nota2 + nota3)/ 4; return Nota5; } double Nota5 = Notas (6.5,7.8, 8.0, 7.1); Nota5 //[Return value]: 7.35 ``` ### Exercício 2 > Crie uma função que implemente a lógica para calcular a área do Retângulo. > ```csharp= using System; // Função Calcular Area Retangulo int AreaRetangulo (int basee, int altura) { int area = (basee * altura); return area; } int b5 = AreaRetangulo (7,3); b5 //[Return value]: 21 ``` ### 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; // área igual public bool RetangulosIguais (double base1, double altura1, double base2, double altura2) { double tri1 = RetanguloArea(base1, altura1); double tri2 = RetanguloArea(base2, altura2); bool igual = tri1 == tri2; return igual; } public double RetanguloArea (double basee, double altura) { double tri = basee * altura; return tri; } bool iguais = RetangulosIguais(5, 4, 2, 10); Console.WriteLine("r2= " + iguais); //r2= True ``` ### Exercício 4 > Crie 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 e R$ 14,00 respectivamente e não sofrerão alteração de preço. > ```csharp= using System; // Calcular Pedido Açaí public double PedidoAcai (int qtdPequeno, int qtdMedio, int qtdGrande) { double totalP = AcaiPequeno(qtdPequeno); double totalM = AcaiMedio(qtdMedio); double totalG = AcaiGrande(qtdGrande); double total = ValorFinal(totalP, totalM, totalG); return total; } public int AcaiPequeno (int qtd) { int total = qtd * 10; return total; } public int AcaiMedio (int qtd) { int total = qtd * 12; return total; } public int AcaiGrande (int qtd) { int total = qtd * 14; return total; } public double ValorFinal (double totalP, double totalM, double totalG) { double total= totalP + totalM + totalG; return total; } double a2 = PedidoAcai(2, 1, 2); Console.WriteLine("a2= " + a2); //a2= 60 ``` ### 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; // Função Calcular Compra de um Veiculo public double CompraVeiculo (double preco, int parcelas) { double taxa = 5; double total = Juros(preco, parcelas, taxa); return total; } public double Juros (double preco, int parcelas, double taxa) { double juros = preco * parcelas * (taxa/100); double total = preco + juros; return total; } double r5 = CompraVeiculo(35000, 12); Console.WriteLine("r5= " + r5); //r5= 56000 ``` ### 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; // Função Cep string nome = "Letícia"; string cep = "04661-200"; bool valido = cep.Contains("-"); int caracteres = cep.Length; Console.WriteLine(valido); Console.WriteLine(caracteres); //True //9 ``` ### 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; //Função Sobrenome public class pessoa { public String nomeCompleto; } public string extrairSobrenome (string nome) { int espaco = nome.LastIndexOf(" "); string sobrenome = nome.Substring(espaco); return sobrenome; } public bool mesmafamilia (pessoa p1, pessoa p2, pessoa p3) { bool iguais = extrairSobrenome (p1.nomeCompleto) == extrairSobrenome (p2.nomeCompleto) && extrairSobrenome(p1.nomeCompleto) == extrairSobrenome (p3.nomeCompleto); return iguais; } pessoa p1 = new pessoa(); p1.nomeCompleto = "Letícia Santos Rocha"; pessoa p2 = new pessoa(); p2.nomeCompleto = "Luana Oliveira Rocha"; pessoa p3 = new pessoa(); p3.nomeCompleto = "Samuel Silva Rocha"; bool a = mesmafamilia (p1, p2, p3) ; Console.WriteLine(a); //True ``` ### 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; //Função Equação do Segundo Grau public class equacao { public int a; public int b; public int c; } public class resultado { public double x1; public double x2; } public double delta (equacao eq) { double d= Math.Pow(eq.b, 2) - 4 * eq.a * eq.c; return d; } public resultado segundograu (equacao eq) { double x1 = (-eq.b + Math.Sqrt(delta(eq))) /2* eq.a; double x2 = (-eq.b - Math.Sqrt(delta(eq))) /2* eq.a; resultado res = new resultado() ; res.x1 = x1; res.x2 = x2; return res; } equacao valoreq = new equacao (); valoreq.a = 1; valoreq.b = - 1; valoreq.c = - 12; resultado r = segundograu (valoreq); Console.WriteLine ("x1 igual a :" + r.x1); Console.WriteLine ("x2 igual a :" + r.x2); //x1 igual a :4 //x2 igual a :-3 ``` ### 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; // Função Maior de 18 public bool entrada (DateTime nascPessoa1) { bool x = nascPessoa1.Month == 9 & nascPessoa1.Day >= 22 | nascPessoa1.Month == 10 & nascPessoa1.Day <= 23; return x; } public bool Signo (DateTime nascPessoa1, DateTime nascPessoa2) { bool x = entrada(nascPessoa1); bool y = entrada(nascPessoa2); bool z = x == y; return z; } bool x = Signo (new DateTime (2004, 10, 21), new DateTime(2003, 10, 23)); x //[Return value]: True ``` ### 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; // Função Abastecimento public double ValorAbastecimento (double iComum, double vComum, double iRodizio, double vRodizio, double consumo) { double KmSemana = Kilometragem(iComum, vComum, iRodizio, vRodizio); double KmMes = KmSemana * 4; double Abastecimento = ValorAbastecimento(KmMes, consumo); return Abastecimento; } public double Kilometragem (double iComum, double vComum, double iRodizio, double vRodizio) { double pNormal = (iComum + vComum) * 4; double pRodizio = iRodizio + vRodizio; double totalP = pNormal + pRodizio; return totalP; } public double ValorAbastecimento (double totalKm, double consumo) { double litros = totalKm / consumo; return litros * 4.9; } double Gasolina = ValorAbastecimento (10, 12, 15, 16, 10); Console.WriteLine("r6= " + Gasolina); ```

    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