Alan Oliveira Rocha Santiago
    • 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
    # Session One: Recomeçar | Fund. Lógica autor: Alan Oliveira Rocha Santiago turma: InfoB número: 02 [TOC] ## Exercicio 1 Crie uma função que implemente a lógica para calcular a média de 4 notas de um aluno. ```csharp= public class NotasAluno { public double n1; public double n2; public double n3; public double n4; } public double CalcularMedia(NotasAluno notas) { double soma = notas.n1 + notas.n2 + notas.n3 + notas.n4; double media = soma/4; return media; } NotasAluno n = new NotasAluno(); n.n1 = 8; n.n2 = 10; n.n3 = 8; n.n4 = 5; double mf = CalcularMedia(n); Console.WriteLine("a media final é de " + mf); ``` ## Exercicio 2 Crie uma função que implemente a lógica para calcular a área do Retângulo. ```csharp= public class Retangulo { public int basee; public int altura; } public int AreaRetangulo(Retangulo ret) { int area = ret.altura * ret.basee; return area; } Retangulo r = new Retangulo(); r.basee = 5; r.altura = 10; int ar = AreaRetangulo (r); Console.WriteLine("a area do retangulo é " + ar); ``` ## Exercicio 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= public class Triangulo { public double basee; public double altura; } public bool AreasIguais(Triangulo tri1,Triangulo tri2) { double a1 = (tri1.basee * tri1.altura)/2; double a2 = (tri2.basee * tri2.altura)/2; bool iguais = a1 == a2; return iguais; } Triangulo t1 = new Triangulo(); t1.basee = 5; t1.altura = 3; Triangulo t2 = new Triangulo(); t2.basee = 5; t2.altura = 6; bool ai = AreasIguais (t1 , t2); Console.WriteLine("as areas dos triangulos são iguais? " + ai); ``` ## Exercicio 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= public class PedidoAcai { public double qtdPequeno; public double qtdMedio; public double qtdGrande; } public double VendaAcai(PedidoAcai pedido) { double ap = pedido.qtdPequeno * 10; double am = pedido.qtdMedio * 12; double ag = pedido.qtdGrande * 14; double total = ap + am + ag; return total; } PedidoAcai p = new PedidoAcai(); p.qtdPequeno = 2; p.qtdMedio = 1; p.qtdGrande = 2; double pa = VendaAcai (p); Console.WriteLine("o total a pagar no pedido do acai é " + pa); ``` ## Exercicio 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= public class CompraVeiculo { public double preco; public double parcelas; } public double CalcularTotalVeiculo(CompraVeiculo compra) { double parcela = compra.preco / compra.parcelas; double taxa = (parcela * 0.05) + parcela; double total = taxa * compra.parcelas; return total; } CompraVeiculo veiculo = new CompraVeiculo(); veiculo.preco = 50000; veiculo.parcelas = 10; double cv = CalcularTotalVeiculo (veiculo); Console.WriteLine("o preco total a pagar pelo veiculo será de " + cv); ``` ## Exercicio 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. ```csharp= public class Endereco { public string nomePessoa; public string cep; } public bool ValidarCEP(Endereco end) { bool vc = end.cep.Length == 9 && end.cep.Contains("-"); return vc; } Endereco vc = new Endereco(); vc.nomePessoa = "Marcelo dos Santos "; vc.cep = "85765-456"; bool validarcep = ValidarCEP(vc); Console.WriteLine(vc.nomePessoa + "o resultado da validação de seu CEP é: " + validarcep); ``` ## Exercicio 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= public class Pessoa { public string nomeCompleto; } public string ExtrairSobrenome(string nome) { int ue = nome.LastIndexOf(" "); string ultimoNome = nome.Substring(ue); return ultimoNome; } public bool MesmaFamilia(Pessoa p1,Pessoa p2, Pessoa p3) { bool sobrenome1 = ExtrairSobrenome(p1.nomeCompleto) == ExtrairSobrenome(p2.nomeCompleto); bool sobrenome2 = ExtrairSobrenome(p1.nomeCompleto) == ExtrairSobrenome(p3.nomeCompleto); bool iguais = sobrenome1 && sobrenome2; return iguais; } Pessoa p1 = new Pessoa(); p1.nomeCompleto = "Waldir Braz"; Pessoa p2 = new Pessoa(); p2.nomeCompleto = "Fernando Braz"; Pessoa p3 = new Pessoa(); p3.nomeCompleto = "Alex Braz"; bool MF = MesmaFamilia(p1,p2,p3); Console.WriteLine("são da mesma familia? " + MF); ``` ## Exercicio 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= 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 termo) { double delta = Math.Pow(termo.b,2) - 4 * termo.a * termo.c; return delta; } public Resultado EquacaoSegundoGrau(Equacao termo) { double rx1 = (-termo.b + Math.Sqrt(Delta(termo))) / 2 * termo.a; double rx2 = (-termo.b - Math.Sqrt(Delta(termo))) / 2 * termo.a; Resultado r = new Resultado(); r.x1 = rx1; r.x2 = rx2; return r; } Equacao resposta = new Equacao (); resposta.a = 1; resposta.b = -1; resposta.c = -12; Resultado res = EquacaoSegundoGrau (resposta); Console.WriteLine("x1 é igual a: " + res.x1); Console.WriteLine("x2 é igual a: " + res.x2); ``` ## exercicio 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= public class Casal { public DateTime nascPessoa1; public DateTime nascPessoa2; } public bool Maior18(DateTime nasc) { DateTime hj = DateTime.Now; bool maior = nasc <= hj.AddYears (-18); return maior; } public bool DeLibra(DateTime nasc) { bool a = nasc.Month == 9 && nasc.Day >= 23; bool b = nasc.Month == 10 && nasc.Day <= 22; return a == true || b == true; } public bool PodeEntrar(Casal p) { bool p1 = DeLibra(p.nascPessoa1) && Maior18(p.nascPessoa1); bool p2 = DeLibra(p.nascPessoa2) && Maior18(p.nascPessoa2); return p1 == true && p2 == true; } DateTime pes1 = new DateTime (2000,10,30); DateTime pes2 = new DateTime (2000,09,23); Casal nasc = new Casal(); nasc.nascPessoa1 = pes1; nasc.nascPessoa2 = pes2; bool permicao = PodeEntrar (nasc); Console.WriteLine ("eles podem entrar na festa? " + permicao); ``` ## Exercicio 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= public class Trajeto { public double distanciaIda; public double distanciaVolta; } public double GastoMensalAbastecimento(Trajeto comum, Trajeto rodizio, double consumo) { double km = ((comum.distanciaIda + comum.distanciaVolta) * 4) + (rodizio.distanciaIda + rodizio.distanciaVolta); double tkm = km * 4; double ta = ((tkm / consumo) * 4) * 3.8; return ta; } Trajeto g = new Trajeto(); g.distanciaIda = 10; g.distanciaVolta = 12; double consumo = 10; double gma = GastoMensalAbastecimento (g , g , consumo); Console.WriteLine("o preco gasto será: " + gma); ```

    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