SophiaPretty

(5)

$14/per page/Negotiable

About SophiaPretty

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Accounting,Algebra See all
Accounting,Algebra,Applied Sciences,Architecture and Design,Art & Design,Biology,Business & Finance,Calculus,Chemistry,Communications,Computer Science,Economics,Engineering,English,Environmental science,Essay writing Hide all
Teaching Since: Jul 2017
Last Sign in: 304 Weeks Ago, 2 Days Ago
Questions Answered: 15833
Tutorials Posted: 15827

Education

  • MBA,PHD, Juris Doctor
    Strayer,Devery,Harvard University
    Mar-1995 - Mar-2002

Experience

  • Manager Planning
    WalMart
    Mar-2001 - Feb-2009

Category > Computer Science Posted 16 Dec 2017 My Price 10.00

Defines a class that has a 10 element integer array

Need help with this. I have the code and the pdf two files.

  • /* Program ID:  Statistics Array with Exceptions Starting File
     * Class:  CSC110AA/CIS163AA
     * Date :
     * Author:  Patricia Baker
     *
     *  Brief Description:  Defines a class that has a 10 element integer array
     *  Methods perform tasks for the array - find max, sum, find average, etc
     * 
     */

    import java.awt.*;
    import java.util.Random;  //for our random number generator




    public class StatsArray {

        private int size;  //how big is the array
        private int[ ] stats; // an array of integers


        //default constructor
        StatsArray() {
            size = 10;
            stats = new int[size];
        }


        public void display(Graphics g)
       {
            int x = 50;  //coordinates for displaying
            int y = 40;
            //display the array with position number
            for(int i = 0; i < stats.length; i++)
             {
                g.drawString("Stats [" + i + "] = "+ stats[i],
                x, (y + 15 * i) );
            }
        }

        public void fillArray()
        {
            //fill the array with random numbers (int) in the range 0 - 100
            Random random = new Random();
            for(int i = 0; i < stats.length; i++)
             {
                stats[i] = random.nextInt(101) ;
           }
        }

        public int getSum()
        {
            //add up all the values in the array
            int total = 0;
            for (int i = 0; i < stats.length; i++)
                total = total + stats[i];
            return total;
        }


        public int getMax()
        {
            //return the maximum value in the array
                int maxValue = stats[0];
                for (int i = 0; i < stats.length; i++){
                    if (stats[i] > maxValue)
                        maxValue = stats[i];
                }
                return maxValue;
        }

        public int getMin()
        {
            //return the minimum value in the array
                int minValue = stats[0];
                for (int i = 0; i < stats.length; i++){
                    if (stats[i] < minValue)
                        minValue = stats[i];
                }
                return minValue;
        }

        public double getAverage()
        {
            //return the average.  must be a double
                return (double)getSum() / stats.length;
        }

        public int countValues(int lowRange, int highRange)
        {
            //count how many numbers are >= lowRange and <= highRange
            int count = 0;
            for (int i = 0; i < stats.length; i++) {
                if ( (stats[i] >= lowRange) && (stats[i] <= highRange) )
                {
                    count++;
                }
            }
            return count;
        }


        public boolean isValueFound(int someNumber) {
            //check to see if someNumber is in the array
            boolean found = false;

            for(int i = 0; (i < stats.length && !found); i++) {
                if (stats[i] == someNumber) {
                    found = true;
                }
            }
            return found;
        }


        public void sortBArray() {
            /*sort the array in ascending order - bubble sort*/

            int tempValue;

            for (int i = 0; i < (stats.length - 1); i++)
            {
                for (int j = (i + 1); j < (stats.length); j++)
                {
                    if (stats[j] < stats[i])
                    {
                        tempValue = stats[i];
                        stats[i] = stats[j];
                        stats[j] = tempValue;
                    }
                }
            }

        }


        public void sortArray() {
                /*sort the array in ascending order - selection sort*/

                int tempValue;
                int min;

                for (int i = 0; i < (stats.length - 1); i++)
                {
                    min = i;
                    for (int j = (i + 1); j < (stats.length); j++)
                    {
                        if (stats[j] < stats[min])
                        {
                            min = j;
                        }
                    }
                    tempValue = stats[min];
                    stats[min] = stats[i];
                    stats[i] = tempValue;


                }

            }




    }

Attachments:

Answers

(5)
Status NEW Posted 16 Dec 2017 02:12 PM My Price 10.00

-----------  ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be----------- qu-----------ick-----------ly

Not Rated(0)