Computação e Programação 2009 / 2010

Documentos relacionados
Instituto Superior Técnico, Dep. de Engenharia Mecânica - ACCAII Objectivos e tarefas

Computação e Programação

Processo de Desenvolvimento

Computação e Programação

COMPUTAÇÃO E PROGRAMAÇÃO 1º Semestre 2010/2011 MEMec, LEAN

COMPUTAÇÃO E PROGRAMAÇÃO

COMPUTAÇÃO E PROGRAMAÇÃO

COMPUTAÇÃO E PROGRAMAÇÃO

Computação e Programação

COMPUTAÇÃO E PROGRAMAÇÃO

COMPUTAÇÃO E PROGRAMAÇÃO

Computação e Programação. MEMec - LEAN 1º Semestre

Divisão de Engenharia Mecânica. Programa de Pós-Graduação em Engenharia Aeronáutica e Mecânica. Prova de Seleção para Bolsas 1 o semestre de 2014

Estruturas de dados complexas: cell arrays e structures

Manipulação de strings e conversão entre tipos de dados

Computação e Programação

Manipulação de strings e conversão entre tipos de dados

Uma solução possível para garantir, em ambiente APEX, a consistência duma estrutura ISA total e disjuntiva.

CANape/vSignalyzer. Data Mining and Report Examples Offline Analysis V

GUIÃO I. Grupo: Continente e Ilha. 1º Momento. Intervenientes e Tempos. Descrição das actividades

Como Mudar a Senha do Roteador Pelo IP o.1.1. Configure e Altere a Senha do seu Roteador acessando o IP Acesse o Site e Confira!

GUIÃO F. Grupo: Minho. 1º Momento. Intervenientes e Tempos. Descrição das actividades

Métodos Formais em Engenharia de Software. VDMToolTutorial

Aula 12 - Correção de erros

RESOLUÇÃO. Computação e Programação (2009/2010-1º Semestre) 1º Teste (11/11/2009) Nome. Número. Leia com atenção os pontos que se seguem:

Divisão de Engenharia Mecânica. Programa de Pós-Graduação em Engenharia Aeronáutica e Mecânica. Prova de Seleção para Bolsas 1 o semestre de 2013

Programação em MATLAB

Para calcular o polinómio de Lagrange noutros pontos Ficheiro polagrangeval.m

LEITURA SUPER RáPIDA (PORTUGUESE EDITION) BY AK JENNINGS

PTC Exercício Programa GABARITO

VGM. VGM information. ALIANÇA VGM WEB PORTAL USER GUIDE June 2016

Slides_Java_1 !"$ % & $ ' ' Output: Run java. Compile javac. Name of program. Must be the same as name of file. Java source code.

Addition of Fields in Line Item Display Report Output for TCode FBL1N/FBL5N

Minicurso de MATLAB. Programa de Educação Tutorial de Engenharia Elétrica. lmax Rodrigues. lcaroline Pereira. lnayara Medeiros

Laboratório de Algoritmos Avançados Capítulo 7

Faculdade de Engenharia. Transmission Lines ELECTROMAGNETIC ENGINEERING MAP TELE 2007/2008

DIBELS TM. Portuguese Translations of Administration Directions

Pesquisa de Marketing: Uma Orientação Aplicada (Portuguese Edition)

Instituto Tecnológico de Aeronáutica

BR localization: Hotfix 109. Technical documentation Documentação Técnica Version Oct 23, de outubro de 2018

Equações de diferenças e aplicações

Units 3 and 4. 3rd Bimester Content. Future Predictions. Life events. Personality adjectives. English - Leonardo Bérenger and Aline Martins

BR localization: Hotfix 003. Technical documentation Documentação Técnica Version Dec 12, de Dezembro de 2018

UNIT 5: Review (UNIDADE 5: Revisão)

Diferenças na Programação com Dataserver Oracle

Computação e Programação Exame Época de recurso

Transcrição:

Computação e Programação 2ª Aula de Problemas Instituto Superior Técnico, Dep. de Engenharia Mecânica - ACCAII Exercícios Resolvidos [Livro 1] (Ver referências no slide 20) 3.3 Write a program to convert a Fahrenheit temperature to Celsius. Test it on the following data (where the reverse conversion is done). 2

Problema 1. Contexto do Problema Converter temperaturas de graus Fahrenheit para graus Celsius. 3 Análise 2.2 Especificações e Requisitos 2.3 Métodos de Processamento 2.1 Entradas 2.1 Saídas Conversão Temperaturas 4

Análise 2.1 Esquema de processamento Entradas: Temperatura em graus Fahrenheit (T_Fahrenheit) Saídas: Temperatura em graus Celsius (T_Celsius) 5 Análise 2.2 Especificações funcionais e Requisitos Édada uma temperatura em graus Fahrenheit O programa calcula e devolve a temperatura correspondente em graus Celsius Precisão do resultado até à segunda casa decimal. 6

Análise 2.3 Fluxo de dados Utilizador Introduz T_Fahrenheit Programa Apresenta mensagem a pedir temperatura para conversão Apresenta T_Celsius 7 Análise 2.3 Métodos de Processamento Conversão de temperaturas: T_Celsius = (T_Fahrenheit 32) * 5/9 8

Algoritmo 3.1 Abordagem Top-Down 9 Algoritmo 3.2 Lista de tarefas Programa pede Temperatura Fahrenheit Utilizador escreve Temperatura Fahrenheit Fazer conversão de temperaturas Apresentar Temperatura Celsius 10

Algoritmo 3.3 Algoritmo i. Programa pede T_Fahrenheit ii. Utilizador escreve T_Fahrenheit iii. T_Celsius = (T_Fahrenheit 32)* 5/9 iv. Apresentar T_Celsius 11 Testes (Algoritmo) 4 Testes T_Fahrenheit Esperado T_Celsius Algoritmo 68 69.8 20 21 20 21 12

Codificação 5 Codificação em Matlab T_Fahrenheit = input('introduza Temp Fahrenheit: '); T_Celsius = (T_Fahrenheit - 32)*5/9; fprintf('temperatura em Celsius: %6.2f º Celsius \n', T_Celsius) 13 Testes (Matlab) 6 Testes à codificação Introduza Temp Fahrenheit: 68 Temperatura em Celsius: 20.00º Celsius Introduza Temp Fahrenheit: 69.8 Temperatura em Celsius: 21.00º Celsius Introduza Temp Fahrenheit: 86 Temperatura em Celsius: 30.00º Celsius 14

Exercícios Resolvidos [Livro 1] (Ver referências no slide 20) 3.4 Write a script which inputs any two numbers (which may be equal) and displays the larger one with a suitable message. 15 Exercícios Propostos [Livro 1] (Ver referências no slide 20) 3.5 Write a script for the general solution of the quadratic equation ax 2 + bx+ c = 0. Your script should be able to handle all possible values of the data a, b, and c. Try it out on the following values of a, b and c: (a) 1, 1, 1 (complex roots); (b) 2, 4, 2 (equal roots of 1.0); (c) 2, 2, 12 (roots of 2.0 and 3.0). 28

Exercícios Propostos [Livro 1] (Ver referências no slide 20) 3.6 Develop a program that computes the solution of two simultaneous linear equations. Test your program using the following equations: x + y = 3 2x y = 3 Solution: x=2, y=1 Hint: begin by deriving an algebraic formula for the solution of the system ax + by = c dx+ ey = f The program should input the coefficients a, b, c, d, e and f. 29 Exercícios Propostos [Livro 2] (Ver referências no slide 20) 1. Write a simple script that will calculate the volume of a hollow sphere which is, where is the inner radius and is the outer radius. Assign a value to a variable for the inner radius, and also assign a value to another variable for the outer radius. Then, using these variables, assign the volume to a third variable. Include comments in the script. 2. The atomic weight is the weight of an atom of a chemical element. For example, the atomic weight of oxygen is 15.9994 and the atomic weight of hydrogen is 1.0079. Write a script that will calculate the molecular weight of hydrogen peroxide, which consists of two atoms of hydrogen and two atoms of oxygen. Include comments in the script. Use help to view the comment in your script. 30

Exercícios Propostos [Livro 2] (Ver referências no slide 20) 2. Write an inputstatement that will prompt the user for a string. Then, find the length of the string. 6. Experiment, in the Command Window, with using the fprintf function for real numbers. Make a note of what happens for each. Use fprintfto print the real number 12345.6789 in the following cases: i. without specifying any field width ii. in a field width of 10 with 4 decimal places iii.in a field width of 10 with 2 decimal places iv.in a field width of 6 with 4 decimal places v. in a field width of 2 with 4 decimal places 9. Write a script to prompt the user for the length and width of a rectangle, and print its area with 2 decimal places. Put comments in the script. 31 Exercícios Propostos [Livro 2] (Ver referências no slide 20) 15. Write a script that assigns values for the x coordinate and then y coordinate of a point, and then plots this using a green +. 17. Create a vector x with values ranging from 1 to 100 in steps of 5. Create a vector y which is the square root of each value in x. Plot these points. Now, use the bar function instead of plot to get a bar chart instead. 32

Referências [Livro 1] Capítulo 3 de EssentialMATLAB for EngineersandScientists, BrianHahne Dan Valentine(2007) Elsevier. [Livro 2] Capítulo 2 de Matlab: A Practical Introduction to Programming and Problem Solving, Stormy Attaway(2009) Elsevier. 33