vitomtolindo
    • 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
    # Final Session | Fundamentos da Lógica **Autor**: Vitório Trindade Santana **Turma**: Informática C **Número**: 50 [toc] ## Nível 1 ### Exercício 1 Faça uma função ÚNICA que a partir da base e altura, calcule a área do triângulo. ```csharp= public double AreaTriangulo (double areaT, double baseT) { double calc = areaT * baseT; double calc2 = calc / 2; return calc2; } double n1q1 = AreaTriangulo (2, 5); //5 ``` ### Exercício 2 Faça uma função ÚNICA que a partir do lado, calcule o perímetro do octógono. ```csharp= public int PerimetroOctogono (int lado) { int calculo = lado * 8; return calculo; } int n1q2 = PerimetroOctogono (9); //72 ``` ### Exercício 3 Faça uma função ÚNICA que a partir da base maior, base menor e altura, calcule a área do trapézio. ```csharp= public int CalculoAreaTrapezio (int bmenor, int bmaior, int altura) { int calculo = ((bmenor + bmaior) * altura) / 2; return calculo; } int n1q3 = CalculoAreaTrapezio (3, 4, 8); //28 ``` ### Exercício 4 Faça uma função ÚNICA que a partir da diagonal maior e menor, calcule a área do losango. ```csharp= public int CalculoAreaLosango (int diagonalmenor, int diagonalmaior) { return (diagonalmenor * diagonalmaior) / 2; } int n1q4 = CalculoAreaLosango (4, 10); //20 ``` ## Nível 2 ### Exercício 2 Faça uma função ÚNICA que a partir de um peso e altura de uma pessoa, calcule o IMC. Arredonde a resposta para duas casas decimais. ```csharp= public double CalculoImc (double peso, double altura) { double altura2 = Math.Pow(altura, 2); double calcimc = peso / altura2; double calcimc2 = Math.Round(calcimc, 2); return calcimc2; } double n2q2 = CalculoImc (68, 1.76); //21.95 ``` ### Exercício 3 Faça uma função ÚNICA que a partir de um capital, parcelas e taxa de juros, calcule o juros compostos. Arredonde a resposta para uma casa decimal. ```csharp= public double CalculoJurosComposto (double capital, int parcelas, double juros) { double taxa = 1 + juros / 100; double taxa2 = Math.Pow(taxa, parcelas); double montante = capital * taxa2; double montante2 = Math.Round(montante, 2); return montante2; } double n2q3 = CalculoJurosComposto (19000, 7, 2); //21825.02 ``` ### Exercício 4 Faça uma função ÚNICA que a partir da massa e velocidade, calcule a energia cinética. Obrigatório o uso da função Math.Pow. ```csharp= public double CalculoEnergiaCinetica (double massa, double velocidade) { double velocidade2 = Math.Pow(velocidade, 2); double calculoenergia = (massa * velocidade2) / 2; return calculoenergia; } double n2q4 = CalculoEnergiaCinetica (10, 3); //45 ``` ### Exercício 5 Faça uma função ÚNICA que a partir da altura e raio, calcule o volume de um cilindro. Obrigatório o uso da função Math.Pow. ```csharp= public double VolumeCilindro (double altura, double raio) { double raioc = Math.Pow (raio, 2); double calcvolume = 3.14 * raioc * altura; return calcvolume; } double n2q5 = VolumeCilindro(4, 2); //50.24 ``` ## Nível 3 ### Exercício 1 Faça uma função ÚNICA que a partir de um nome completo de uma pessoa, extraia o primeiro nome. ```csharp= public string PrimeiroNome (string nome, string sobrenome, string ultimonome) { string completo = nome + sobrenome + ultimonome; int tamanho = nome.Length; string recorte = completo.Substring(0, tamanho); return recorte; } string n3q1 = PrimeiroNome ("Gabriel ", "Silva ", "Santos"); //Gabriel ``` ### Exercício 2 Faça uma função ÚNICA que a partir de um nome completo de uma pessoa, extraia o último nome. ```csharp= public string UltimoNome (string nome, string sobrenome, string ultimonome) { string completo = nome + sobrenome + ultimonome; int posicao = completo.LastIndexOf(" "); int tamanho = ultimonome.Length; string recorte = completo.Substring(posicao + 1, tamanho); return recorte; } string n3q2 = UltimoNome ("Ednaldo ", "Pereira ", "Santos"); //Santos ``` ### Exercício 3 Faça uma função ÚNICA que a partir de um e-mail de uma pessoa, extraia o domínio do e-mail. ```csharp= public string DominioEmail (string email) { int posicao = email.IndexOf("@"); return email.Substring(posicao, 10); } string n3q3 = DominioEmail ("garbmil10@gmail.com"); //@gmail.com ``` ### Exercício 4 Faça uma função ÚNICA que a partir de um CEP, retorne verdadeiro/falso se o CEP contém o caractere hífen (-) e possui um total de 9 caracteres. ```csharp= public bool VerificarCep (string cep) { bool verificacao = cep.Contains("-") && cep.Length == 9; return verificacao; } bool n3q4 = VerificarCep ("25789-987"); //true ``` ## Nível 4 ### Exercício 1 Faça uma função ÚNICA que a partir de uma data, descubra o último dia do mês a partir dessa data. ```csharp= public DateTime PrimeiroDia (DateTime data) { DateTime a = new DateTime(data.Year, data.Month, 1); DateTime b = a.AddMonths(1); return b; } DateTime x = DateTime.Now; DateTime n4q2 = PrimeiroDia (x); // 5/1/2021 ``` ### Exercício 3 Faça uma função ÚNICA que a partir de uma data, retorne verdadeiro/falso se a data pertence ao segundo trimestre do ano. ```csharp= public bool SegundoTrimestre (DateTime data) { int mes = data.Month; bool sera = mes >= 4 && mes <= 6; return sera; } DateTime d = new DateTime(2021, 04, 16); bool n4q3 = SegundoTrimestre (d); //true ``` ### Exercício 4 Faça uma função ÚNICA que a partir de uma data, retorne verdadeiro/falso se a pessoa tem mais de 18 anos a partir do dia atual. ```csharp= public bool VerificarMaiordeIdade (DateTime nascimento) { DateTime a = DateTime.Now; DateTime b = a.AddYears(-18); bool confere = nascimento <= b; return confere; } DateTime minhadata = new DateTime(2004, 12, 26); bool sera = VerificarMaiordeIdade (minhadata); //false ``` ### Exercício 5 Faça uma função ÚNICA que a partir de uma data, retorne verdadeiro/falso se a data pertence a primeira quinzena do mês. ```csharp= public bool PrimeiraQuinzenaDoMes (DateTime data) { int a = data.Day; bool verificar = a >= 1 && 15 >= a; return verificar; } DateTime b = DateTime.Now; bool n4q5 = PrimeiraQuinzenaDoMes (b); //false ``` ## Nível 5 ### Exercício 1 Faça uma função COMPOSTA que a partir dos valores 'a', 'b' e 'c’, calcule o valor de 'x’ baseado na equação de segundo grau. ```csharp= public double CalculoEquacao2Grau (double a ,double b , double c) { double b2 = Math.Pow(b, 2); double equacao = EquacaoDo2Grau (a , c); double x = b2 + equacao; return x; } public double EquacaoDo2Grau (double a, double c ) { double x = -4 * a * c; return x ; } double n5q1 = CalculoEquacao2Grau (1, -4, -12); //64 //obs = Se colocar o sinal de subtração na double x da função CalculoEquacao2Grau o cálculo fica errado porque a máquina vai somar o sinal de subtração e o que veio na variavel equacao. ``` ### Exercício 2 Faça uma função COMPOSTA que encontre um termo de uma PA (Progressão Aritmética), a partir do primeiro termo, razão e posição do termo que deseja encontrar. ```csharp= public int CalculoPA (int a1, int razao, int an) { int n = InicioCalculoPa (razao, an); int calculofinal = a1 + n; return calculofinal; } public int InicioCalculoPa (int razao, int an) { return (an -1) * razao; } int n5q2 = CalculoPA (5, 5, 25); //125 ``` ### Exercício 3 Faça uma função COMPOSTA que encontre um termo de uma PG (Progressão Geométrica), a partir do primeiro termo, razão e posição do termo que deseja encontrar. ```csharp= public double CalculoPG (int a1, int razao, int an) { double An = InicioCalculoPg (razao, an); double finalcalculo = a1 * An; return finalcalculo; } public double InicioCalculoPg (int razao, int an) { double razao2 = Math.Pow(razao, an - 1); return razao2; } double n5q3 = CalculoPG (3, 4, 5); //768 ``` ### Exercício 4 Faça uma função COMPOSTA que a partir de dois nomes completos, retorne verdadeiro/falso se as pessoas são da mesma família, comparando o último nome das duas pessoas. ```csharp= public bool ConferirParentesco (string nome1, string sobrenome1, string ultimonome1, string nome2, string sobrenome2, string ultimonome2) { string nomec1 = NomeCompleto1 (nome1, sobrenome1, ultimonome1); string nomec2 = NomeCompleto2 (nome2, sobrenome2, ultimonome2); bool confere = nomec1 == nomec2; return confere; } public string NomeCompleto1 (string nome1, string sobrenome1, string ultimonome1) { string nome = nome1 + sobrenome1 + ultimonome1; int posicao1 = nome.LastIndexOf(" "); int tamanho = ultimonome1.Length; string nomef = nome.Substring(posicao1, tamanho); return nomef; } public string NomeCompleto2 (string nome2, string sobrenome2, string ultimonome2) { string nome = nome2 + sobrenome2 + ultimonome2; int posicao = nome.LastIndexOf(" "); int tamanho = ultimonome2.Length; string nomef = nome.Substring(posicao, tamanho); return nomef; } bool n5q4 = ConferirParentesco ("Gustavo ", "Henrique ", "Silveira", "João ", "Guilherme ", "Silva"); //false ```

    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