CHE 210 HW1 Solution

CHE 210 HW1 Solution - %0.1f\n',n); fprintf('\nFinal...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
% J. Steven Swinnea % Homework 1 ChE210 Fall 2010 % A script to calculate the volume of a hollow sphere % Inputs ro = input('Enter outer radius: '); ri = input('Enter inner radius: '); % Calculation vol = 4*pi/3*(ro^3 - ri^3); % Outputs fprintf( '\n' ); % a blank line fprintf( 'Outer Radius: %7.1f\nInner Radius: %7.1f\n',ro,ri); fprintf( ' Volume: %7.1f\n',vol); >> sphere_volume Enter outer radius: 5 Enter inner radius: 4 Outer Radius: 5.0 Inner Radius: 4.0 Volume: 255.5 >> sphere_volume Enter outer radius: 10 Enter inner radius: 9 Outer Radius: 10.0 Inner Radius: 9.0 Volume: 1135.2
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
% Determines the Balance in a savings account % with an interest Rate expressed in percent, % an Initial balance after N years. A = input('Initial Investment: '); r = input('Interest Rate (percent): '); n = input('Number of Years: '); B = A*(1+r/100)^n; fprintf('\nInitial Balance: %0.2f\n',A); fprintf(' Interest Rate: %0.1f\n',r); fprintf('Number of Years:
Background image of page 2
Background image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: %0.1f\n',n); fprintf('\nFinal Balance: %0.2f\n',B); >> interest Initial Investment: 10000 Interest Rate (percent): 4.3 Number of Years: 5 Initial Balance: 10000.00 Interest Rate: 4.3 Number of Years: 5.0 Final Balance: 12343.02 >> interest Initial Investment: 5000 Interest Rate (percent): 6 Number of Years: 6 Initial Balance: 5000.00 Interest Rate: 6.0 Number of Years: 6.0 Final Balance: 7092.60 % Determines the angle between sides a and b of % a triangle using law of cosines. a = input('Enter Side A: '); b = input('Enter Side B: '); c = input('Enter Side C: '); % Could solve as a single assignment cosgamma = (a^2 + b^2 - c^2)/(2*a*b); angle = acosd( cosgamma ); fprintf('\nA: %3d B: %3d C: %3d\n', a , b, c ); fprintf('Angle: %0.2f\n',angle); >> triangle_angle Enter Side A: 18 Enter Side B: 35 Enter Side C: 50 A: 18 B: 35 C: 50 Angle: 139.00 >> triangle_angle Enter Side A: 3 Enter Side B: 4 Enter Side C: 5 A: 3 B: 4 C: 5 Angle: 90.00...
View Full Document

This note was uploaded on 09/26/2010 for the course CHE 210 taught by Professor Swinnea during the Fall '08 term at University of Texas.

Page1 / 3

CHE 210 HW1 Solution - %0.1f\n',n); fprintf('\nFinal...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online