Specification for Profit/Loss Project -- version 6

Building upon the previous versions, make a new version (in a new file) with the following improvements and changes:
Avoid doing any I/O or computation im the "main()" method. (See suggested code, below.)
         /*  (NOTE: The following code is given for illustration only.) */
	public static void
	main( String[] z ) {
	  //DECLARATIONS:
	  ...
	  //INPUT:  Get sales data from file.
          String f=  asks( "Please enter the file name for the sales data.  " );
	  many=  readarray( sales );		// Read sales data into array.  

	  //INPUT:  Get scalar parameters.
          double price=  askd( "Price per unit sold (first month)" );
          double pinc3=  askd( "Quarterly price increase (%)" );

          double fixed=  askd( "Fixed expense (first month)" );
          double expPct=  askd( "% increase in fixed expenses, month-to-month." );
          double expIncr=  askd( "Additional monthly increase ($) for fixed exp." );
 
          double mat=  askd( "Materials cost per item (first month)" );
          double matinc=  askd( "Materials cost increase (%), monthly" );

          double labor=  askd( "Labor cost per item (first month)");
          double labinc=  askd( "Labor cost incr(%) after months 6 & 18. );


	  //PROCESSING:  Fill arrays (revenues & expenses) with generated values
	  fillrev( rev, many, sales, price, pinc3 );		// Calculate the revenues,
	  fillexp( exp, many, sales, fixed, exppct, expIncr, mat, matinc, labor, labinc );	// Calculate expenses,
	  calcprofit( profit, many, rev, exp );			// Calculate profits,

	  //OUTPUT:  Produce reports, as required.
	  report( many, month, sales, rev, exp, profit );		// Standard report

	  sort( profit, many, monthnum, ... );				// Sort by profit
	  report( many, month, sales, rev, exp, profit );

	  sort( exp, many, monthnum, ... );				// Sort by expense
	  report( many, month, sales, rev, exp, profit );

	  sort( monthnum, many, ... );					// Sort by monthnum (again)
	  report2( many, month, sales, rev, exp, profit );		// Report only when sales up 10%

	  summary( many, sales, rev, exp, profit, ... );		// avg & variance for each
	}







	


Mean Average, Variance, and Standard Deviation

To compute the variance of a set of values, we must first compute the mean average which is simply the total of all the values divided by the number of values. Then compute the variance, by squaring the differences between each value and the mean, and summing up these squared differences. The following code may be used to compute the variance "v" of an array "a[]" containing "m" values, with a mean average of "avg".
	sum=  0;
	for (j=0; j<m; j++) {
		dif   =   a[j] - avg;	// Difference
		difsq =   dif * dif;	// Square it.
		sum   +=  difsq;	// Sum the squares of the differences.
	}
	variance=  difsq / (double) m;	// Divide by number of values.
					// (NOTE:  m-1 is used, in some cases.) 
NOTE:   The standard deviation, or "root mean squared" is the square-root of the variance.



Specification for Profit/Loss Statement -- versions 1, 2, 3, and 4


IDENTIFICATION: XYZloss.java
(where XYZ represents your initials)
PURPOSE: Produce a profit/loss projection,
and display the monthly information
sorted in various ways.

Version 1

Using arrays initialized with test data, produce a report similar to the following:

Month Sales Revenues Expenses Profit (Loss)
1 100 200.00 1000.00 - 800.00
2 200 400.00 1500.00 -1100.00
3 400 800.00 2000.00 -1200.00
4 800 1600.00 2500.00 - 900.00
5 1600 3200.00 3000.00 200.00
6 3200 6400.00 3500.00 2900.00
... ... ... ... ...
24 4096 ... ... ...
You will need arrays such as the following (They may be "global".): Set the price per item to $10.

Version 2

Produce a similar report, with rows rearranged from highest profit to lowest (i.e. greatest loss).
To do this, you must sort all the arrays, using profit as the "key" field.

Also produce a similar report showing all data, but with rows rearranged from highest to lowest expense amounts.
To do this, you must sort all the arrays, using expenses as the "key" field.

Finally, add another report with the months listed in alphabetical order.   (This was removed from the project.)

Versions 3 & 4

Remove the test data, and initialize the arrays based upon input values such as the following: