0
/*

 Program Name:  MonthlySales.java
 Author:    Dominick Saccoccio
 Date:      2-19-08
 Description: The program provides an end-of-the-year sales analysis for a company.
              The revenue contains total sales for each month, where revenue
              ={ 16692, 2504, 2463, 1857, 2369, 2684, 3374, 2630, 2531, 1928, 2692, 2578}
              presents the sales of January to December.

 */
   public class MonthlySales

    {
        private  final  int  JANUARY = 1;
        private  final  int  DECEMBER = 12;
        private  int [ ] REVENUE = { 0, 16692, 2504, 2463, 1857, 2369,3684, 2374, 2630, 2531, 1928, 2692, 2578 };




            public int total ( )
            {

                int sum = 0;
                for (int i = JANUARY; i <= 12; i++)
                    sum += REVENUE[i];
                return sum;
            }

            public int average ( )
            {
                int aver;

                aver = total()/ 12;

                return aver;
            }

            public int hightestMonth ( )
            {
                int highest;
                int i;

                highest = REVENUE[0];
                double sum = REVENUE[0];
                for(i = 1; i < 12; i++)
                {
                    sum = sum + REVENUE[i];
                    if(REVENUE[i] > highest)
                    highest = REVENUE[i];
                }
                return highest;

            }

            public int monthsRevenue (int month)
            {
                month = 0;

                return month;

            }
            public void printTable ( )
            {
                System.out.println(REVENUE [i]);

            }



    }     // end of MonthlySales class

Edited by mike_2000_17: Fixed formatting

4
Contributors
5
Replies
6
Views
9 Years
Discussion Span
Last Post by piers
0

how to find the highest number in the array and also how to print the array in a table form

0

you just store the first element of the array in an int, double, or whatever you want to use,
compare it to all the other elements and if you find one that is bigger in value, you store that one in that variable.

in you jsp file (at least, that's what I think you're creating)
you could use something like this:

<%
    double[] row = request.getAttribute("row");
    while(row.hasMoreElements()){
        out.print(row.nextElement());
    }
%>

Edited by mike_2000_17: Fixed formatting

0

To print in something like a table format on the command line use "/t" and "/n" in System.out.print();

If you want a table format using a gui then look at the libraries on the JAVA API website.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.