CHE 210 HW1 Solution - %0.1f\n,n fprintf\nFinal...

Info icon This 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
Image of page 1

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

View Full Document Right 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:
Image of page 2
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

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern