All pastes #1745029 Raw Edit

David A. Chapman

public cpp v1 · immutable
#1745029 ·published 2010-01-10 04:56 UTC
rendered paste body
/*PROGRAMMER: David A. ChapmanFILE: arcLength.cppPURPOSE: Calculate the arc length of a circle based the angle and radius.FORMULA: arc length equals two times pi by the radius multiplied by the 		 central angle (in degrees) over three hundred and sixty.*//* include directives */#include <iostream>#include <stdio.h>/* name scope */using namespace std;/* calculate_arc_length() function prototype */double calculate_arc_length(double& angle, double& radius);/* calculate_arc_length() function definition */double calculate_arc_length(double& angle, double& radius){	return 2 * 3.142 * radius * (angle / 360);}/* main() function */int main(void){	/* variables will be defined by user input */	double angle, radius;	char again;		/* promp the user of the program's purpose */	cout << "This program calculates the arc length of a circle."		 << endl		 << "The input for the central angle should be in degrees.\n"		 << endl;	/* loop the input and output for multiple calculations */	do	{		/* prompt the user for in central angle */		cout << "Enter the central angle in degrees." << endl;		cout << ":> ";		cin  >> angle;		/* prompt the user for the radius length */		cout << "Now enter the the length of the radius." << endl;		cout << ":> ";		cin  >> radius;			/* call calculate_arc_length() to output the arc length to the user */		cout << "The arc length is " << calculate_arc_length(angle, radius)			 << endl;			/* ask user if they need to do more calculations */		cout << "Do another calculation? (Y/N): ";		cin  >> again;	}	while(again == 'Y' || again == 'y');	/* prompt the user to press enter so that the program can close */	cout << "\nPress [ENTER] to close this window...";	getchar();		return 0;}