okay so this is what I have so far, still need some help unfortunately…comments are also included! Those big starred boxes are function comment blocks, don't know if thats a universal thing or just something my teacher likes to do

Code:

#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <fstream> //required for file streaming
#include <cctype>
#include <ctime>
using namespace std;
/************************************
Function Name: Rand_Float
This function generates a random value
between a and b.
Passed: a = min value
b = max value
Returned: random double value
************************************/
double Rand_Float(double a, double b)
{
return ((double)rand()/RAND_MAX)*(b-a) + a;
}
/*************************************
Function Name: Distance
This function calculates the distance from
the light to the floor
Passed: measurement_1 = base
measurement_2 = height
Returned: distance
**************************************/
double Distance(double measurement_1, double measurement_2)
{
double distance;
distance = sqrt(measurement_1*measurement_1+measurement_2*measurement_2);
return distance;
}
double Intensity(int power, double Distance)
{
double intensity;
intensity = power/(Distance*Distance);
return intensity;
}
int main()
{
//Declare objects
srand(time(0));
char option;
int num_floodlights;
char given_random;
double measurement_1, measurement_2, measurement_3, measurement_4;
double distance;
double intensity;
int power;
int height;
int loop(0);
const double a(70.5);
const double b(1);
const int NROWS(94);
const int NCOLS(50);
double court[NROWS][NCOLS];
int i, j;
//Read in values
lights >> option >> num_floodlights >> given_random >> measurement_1 >> measurement_2 >> measurement_3 >> measurement_4 >> power >> height;
//While loop that will run through the first two options of light placement
while(option != 'C')
{
for (i=0;i<NROWS;i++)
{
for (j=0;j<NCOLS;j++)
{
//Call the functions
distance = Distance(measurement_1, measurement_2);
intensity = Intensity(power, distance);
court[i][j]=intensity;
cout << setprecision(2) << "\t" << court[i][j];
}
}
//Read in next option
lights >> option >> num_floodlights >> given_random >> measurement_1 >> measurement_2 >> measurement_3 >> measurement_4 >> power >> height;
}
system("pause");
return 0;
}

## Bookmarks