1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
#include<iostream> //Required for cin, cout
#include<cmath>
using namespace std;
int
main ()
{
double G(pow(6.67,-11)), rad,kb(pow(1.38,-23)), RadCore, meanmolweight(0.6060), centdens(160), protonmass(pow(1.67,-27)), x_incr, temp, estmass, a, b, new_x; // Declare objects in main()
int Number, loop;
cout <<
"Enter the radius of the star in km\n";
cin >> rad;
cout <<
"Enter the radius of the core in km\n";
cin >> RadCore;
cout <<
"Enter the estimated mass of the star in kg\n";
cin >> estmass;
cout << "Enter endpoint range a and b (a<b) (First the core and then surface temperature of the star) of the function to be plotted \n";
cin >> a >> b;
cout <<
"Enter the number of points you want over the range of 'a' to 'b'\n";
cin >> Number;
x_incr = (b - a) / Number; // increment between the points based on number wanted
loop = int (b - a) / x_incr; // loop gives the for loop repetitions equal to number points wanted
cout << loop; // check that shows loop and Number are the same
cout.setf (ios::fixed);
cout.precision (2); // Set Formats
cout << "Temperature and Radius (new_x) \n";
for (int k = 0; k <= loop; k++)
{
new_x = a + k * x_incr;
temp = ((5*M_PI*G*estmass*protonmass)/(36*kb))*centdens*pow(rad,2)*(1+(RadCore/rad)-((19*pow(RadCore,2))/(5*pow(rad,2)))+(((9*pow(RadCore,3))/(5*pow(rad,3)))));
cout << new_x << " " << temp << endl; //echo vales to screen
}
return 0; } // Exit program.
/*Enter the radius of the star in km
70000000
Enter the radius of the core in km
10000
Enter the estimated mass of the star in kg
1.9e+20
Enter endpoint range a and b (a<b) (First the core and then surface temperature of the star) of the function to be plotted
20000
6000
Enter the number of points you want over the range of 'a' to 'b'
10
10Temperature and Radius (new_x)
20000.00 89420920672767955991265280.00
18600.00 89420920672767955991265280.00
17200.00 89420920672767955991265280.00
15800.00 89420920672767955991265280.00
14400.00 89420920672767955991265280.00
13000.00 89420920672767955991265280.00
11600.00 89420920672767955991265280.00
10200.00 89420920672767955991265280.00
8800.00 89420920672767955991265280.00
7400.00 89420920672767955991265280.00
6000.00 89420920672767955991265280.00 */
|