I just made a program to calculate the distance to a rainbow...it seemed to work. ..but the Prof wants that version which I think is callled "Interactive" and he wants an "Noninteractive" version. That would be be with InData.txt files. Well I did that and when I went to test the program it just said "Press any key to continue" thats it. I checked the files and there was an Output.txt file with the answers..is this what this should do? Only show the outpt.txt file vs. showing on the comptuer screen. I hope this is right, please let me know. thanks
Bryan
Here is my Noninteractive version...Please let me know if this is built correctly.
Code:
//*****************************************
//How tall is a rainbow
//This program finds out how tall a
//rainbow is with the distance of the
//rainbow already defined by the programmer
//*****************************************
#include <iostream>
#include <iomanip>
#include <fstream>
#include <cmath>
using namespace std;
float PI;
float MagicAngle;
float RadiansMa;
float TangentMa;
float RainbowDistance;
float RainbowHeight;
ifstream InData;
ofstream OutData;
int main()
{
OutData << fixed <<showpoint;
InData.open("InData.txt");
OutData.open("OutData.txt");
const double PI = 3.14159265;
const double MagicAngle = 42.3333333;
InData >> RainbowDistance;
RadiansMa = MagicAngle * PI/180;
TangentMa = tan(RadiansMa);
RainbowHeight = TangentMa * RainbowDistance;
OutData << setprecision(4);
OutData << "Distance is " <<RainbowDistance << endl
<< "Height of rainbow is " <<RainbowHeight <<endl;
return 0;
}