final int SIZE=24; int monthnumber[SIZE]; int many=SIZE; fillmonths( monthnumber, many );
int price; // Price per unit sold (first month). double pinc3; // Quarterly price increase (%), in months 4, 7, 10, etc. double fixed; // Fixed expenses (for first month). double expPct; // Percentage increase in fixed expenses, month-to-month. double expIncr; // Additional monthly increase amount ($) for fixed expenses. //// fixed= fixed * (100+expPct)/100. + expIncr; double mat; // Materials cost per item (first month). double matinc; // Materials cost increase (%), monthly. double labor; // Labor cost per item (first month) double labinc; // Expected labor cost incr(%) after months 6 & 18. String f; // Name of file containing the monthly sales data. /* (NOTE: The above code is given for illustration only.) */
/* (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 }
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.
IDENTIFICATION: | XYZloss.java
(where XYZ represents your initials) |
PURPOSE: | Produce a profit/loss projection, and display the monthly information sorted in various ways. |
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 | ... | ... | ... |
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.)
//// Some of your code might look similar to the following: // Compute fixed expenses for this month. exp[j] = exp[j-1] * (1.0 + expPct/100. ) + (expIncr) // Compute sales volume for this month. pct= salesInc1 OR salesInc2 (depending on which month). sales[j] = sales[j-1] * (1.0 + pct/100. )