... the user, and then calculates the volume of the cylinder by using the following formula: Volume = radius * radius * height * 3.1416
Answers (1)
Your welcome.... :)
Hello jignesh144,
You did such a wonderful job on answering my first question I was hoping you may be able to answer this one.
Could you explain to me what is the difference between a sequential control structure and a selection control structure? Also, could you explain how both control structures could be used in the algorithm for the simple task of making a peanut butter sandwich and what would that code look like?
Sequential:
Start
prompt: Input
Processing
display: Output
END
Selection:
Start
Prompt: Score
IF Score>=90 Then
Display: Grade=A
ENDIF
END
From the above code u'll understand the diffrence.... its simply using if-else... and u using selection... :)
Awesome!! That was very helpful. Thanks again!!
Could you please help me with this one?
What are the differences between a pre-test loop, a post-test loop, and a For (built-in counter-controlled) loop? Explain how one of those three loops could be used in the algorithm for the simple task of making a peanut butter sandwich.
Pretest loop runs 0 or more times
while (condition)
{
// do something
}
post test loop runs 1 or more times but at least once
do {
// do something
} while (condition);
The For loop uses a built-in counting procedure to repeat a series of instructions a specific number of times.
For (intCounter = 1 TO 5)
{
Print intCounter;
Next
}
And no idea about Peanut-butter... Lets c, if ill come to know, ill surely let u know.... :)
Thank you so much!
Your welcome.... :)
Hey there Jignesh! Hey how would the flow charts and pseudocode look for this?
The Metric Conversion application is a menu-driven program. First, the program displays a Main Menu that states the purpose of the program and allows the user to select one of five metric system measurements or quit the program in the following manner:
Press the 1 key to convert meters to U.S. yards
Press the 2 key to convert kilometers to U.S. miles
Press the 3 key to convert kilograms to U.S. pounds
Press the 4 key to convert milliliters to U.S. ounces
Press the 5 key to convert liters to U.S. gallons
Press the 6 key to quit the program
After the user selects a metric measurement and the program confirms the entry is valid, the program prompts the user to enter an amount of the selected metric measurement (0.0 to 10000.0). For example, if the user selected the first menu option, the prompt message should be displayed in the following manner:
Enter the amount of meters to convert:
After user enters a metric measurement amount and the program confirms the entry is valid, the program converts the metric amount to an equivalent amount of a corresponding U.S. measurement.
Finally, the program then displays the equivalent U.S. measurement amount in the following manner:
10.25 meters is equivalent to 11.2094 U.S. yards
Here are the metric system measurements and U.S. conversions to be used:
Conversion Type: Conversion Formula:
Meters to yards 1 meter = 1.0936 U.S. yards
Kilometers to miles 1 kilometer = 0.6214 U.S. miles
Kilograms to pounds 1 kilogram = 2.205 U.S. pounds
Milliliters to ounces 1 milliliter = 0.0338 U.S. ounces
Liters to gallons 1 liter = 0.264 U.S. gallons
#include<iostream.h>
class conv
{
double meter,miles,kilometer,kilogram,milimeter,liter;
double km,yard;
int x;
public:
void in()
{
cout<<"Enter the option:";
cout<<"\n";
cout<<"1. meters to U.S. yards";
cout<<"\n";
cout<<"2. kilometers to U.S. miles";
cout<<"\n";
cout<<"3. kilograms to U.S. pounds";
cout<<"\n";
cout<<"4. milliliters to U.S. ounces";
cout<<"\n";
cout<<"5. liters to U.S. gallons";
cout<<"\n";
cout<<"6. Quit";
}
void transform()
{
cin>>x;
switch(x)
{
case 1:
{
cout<<"Enter the amount of meters to convert:";
cin>>meter;
yard=meter*1.0936;
cout<<yard;
}
case 2:
{
cout<<"Enter the amount of miles to convert:";
cin>>miles;
km=miles*1.0936;
cout<<km;
}
//similarly other cases...
}
}
};
void main()
{
conv c;
c.in();
c.transform();
}
//I wrote this code... Try it out... (needs some modifications though) & Will try to give u flowchart soon...
And write "break;" w/o quotes after cout<<yard & cout<<km in both the cases... :)
Wow! Thank you so very much.