In: Computer Science
Objectives:
Learn to analyze a computational problem and construct an algorithm to solve it
Learn to use sequential statements to build a basic program to implement the algorithm, using correct programming format
Learn to use the scanf function to read and store values entered on the keyboard by the user, and the printf function used to display output results on the computer monitor
Learn to convert math formulas into correct arithmetic expressions using variables, constants, and library math functions
Learn to construct a test plan and provide appropriate documentation
Description: This programming assignment requires you to compute the number of helium-filled balloons of a specified diameter required to lift a person with a specified weight off the ground.
Instructions:
Inputs: The required input values to be provided by the user are the weight of the person in pounds (a double), and the diameter of each balloon (an integer). Assume the balloon material is foil/mylar. Other values needed (a value for pi, for example) should be defined as constants.
Output: Display all input and computed values, including “explanatory text”. The final output value to be displayed is the number of balloons required (an integer).
Formulas: Show all formulas used for this problem, with explanations, units, and any helpful sketches. You will need the formula for computing the volume of each balloon (assume a perfectly spherical shape, ignoring the air valve), and some basic facts about helium:
o Volume of a sphere: v = 4/3πr3
o Facts about helium: Less dense than regular air, helium weighs 0.0114 lb/ft3 due to the force of gravity pulling down. The air pushes up with a force equal to the weight of the air the helium displaced, or 0.0807 pounds. The difference between the up and down forces is 0.069 pounds, and as a result, each cubic foot of helium can lift 0.069 pounds.
Identify values that would be valid vs. invalid for computing the number of balloons
(although you will not include testing of invalid values in this lab). Identify any known factors disregarded.
Algorithm: Document your algorithm, numbering the steps.
Example solution: Compute the solution by hand using your algorithm and example values. You may use the following example values for testing:
o 100 lbs for the weight of the person
o ? in. balloon (class suggests)
Testing: Document your test plan. After you construct your program, test it using the same example values as used in the example solution and include screenshots of the output in your report.
Scoring: Your grade for this assignment will be determined by five criteria:
Do your programs compile and run, producing the correct results according to the instructions?
Do your programs demonstrate good programming practices, such as well-documented code with comments, effective use of white space, proper indentation, appropriate variable names, etc.?
Have you tested your programs as instructed and included screenshots of output results?
Have you submitted a completed Lab Report?
Are you submitting your assignment on time?
Algorithm
Step 1: Start
Step 2 : Input the Values Weight and Diameter.
Step 3 : r= diameter/2
Step 4 : V= 4/3*3.14* (r ^ 3)
Step 5 : A= 0.069
Step 6 : total = V+A
Step 7 : NumberOfBellons= Weight/total
Step 8 : Output NumberOfBellons
Step 9 : Stop.
Programe :
# include <Stdio.h>
# include <math.h>
int main()
{
double w,v,tot;
int d,n,r;
printf("\n Enter The Persion Wight : ");
scanf("%lf",&w);
printf("\n Enter Diameter of each baloon : ");
scanf("%d",&d);
r= d/2 ;
v=4/3*3.14*(pow(r,3)); //Volume of a sphere//
tot= v + 0.069;
n= w/tot ;
printf("\n %0.2lf Weight of a persion ",w);
printf("\n %d diameter of baloon",d);
printf("\n No of beloon is : %d",n);
return 0;
}
Output:
Case 1
Enter The Persion Wight : 100
Enter Diameter of each baloon : 3
100.00 Weight of a persion
3 diameter of baloon
No of beloon is : 31
Case 2
Enter The Persion Wight : 112.36
Enter Diameter of each baloon : 3
112.36 Weight of a persion
3 diameter of baloon
No of beloon is : 35
Case 3
Enter The Persion Wight : 134.35
Enter Diameter of each baloon : 4
134.35 Weight of a persion
4 diameter of baloon
No of beloon is : 5