I have gotten the program to compile and display the words, but I cannot put the inputs in to finish the program. What is wrong with it? Thanks.
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
int c,v,lo,l;
c = 299792458
cout << "This program will solve the lorentz and FitzGerald contraction formula. " << endl;
cout << "The formula states that L = length times the square root of one minus velocity squared divided by the. " << endl;
cout << "speed of light squared. " << endl;
cout << "Enter the length. " << endl;
cin >> lo;
cout << "Enter the velocity. " << endl;
cin >> v;
l = lo * sqrt(1.0 -(pow(v, 2.0) / pow(2.0)));
cout << "The contraction is" << endl;
cout << l << endl;
Are you getting error messages or is the answer just not accurate?
1.) There needs to be a ; after giving c a value. (error message)
2.) If the problem is about accuracy I suggest declaring your ints as doubles instead so that they can deal in decimal points. double c,v,lo,l;
3.) You need the speed of light into your actual calculations. (Thank you Wikipedia). l = lo * sqrt(1.0 -(pow(v, 2.0) / pow(c, 2.0)));
I haven't actually run your program through my compiler, so there may be more issues, but that's what I've got so far.
Interesting program for a first project, looking forward to seeing more.
I have gotten the program to work now, but I need to have it round to four decimal points and when i type that in, I don't get an output. What might be causing that?