Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I have to work on a Java Program with the following steps: Use a method called p

ID: 3864332 • Letter: I

Question

I have to work on a Java Program with the following steps:

Use a method called process() that will be used to perform the element by element multiplication of thematching price and quantity variables.

Use a method called display() that will be used to display the program’s output as shown in the following Figure 1 screen snapshot.

Both these methods will receive both the price and quantity arrays and either perform multiplication on the arrays or display the result of the multiplication.

After the running the program and checking that the program works, I have to modify the program with the following steps:

within the display() method a separate for loop that will display the following table, which shows the amount status as either being above or equal to $ 100.00 or being strictly below $ 100.00 . Store the status character in a global array defined as statusArray()with 'A' for ABOVE and 'B' for BELOW.

Testing the program that should display the below table:

1) B 2) A 3) B 4) A 5)A 6)A 7)B 8)A 9)B 10)B

This is the code I started:

/********************************************************************

Program Name: ArrayProcessing.java

Programmer's Name: Sammy Student

Program Description: Manipulation of three arrays ********************************************************************/

// include any necessary packages / libraries

importjava.text.DecimalFormat;

//the class file

public class ArrayProcessing

{

// declare the global variables for the array indices

public static final int index = 10;

public static int count = 0;

// declare the three arrays

public static double[] priceArray =

{ 5.73, 11.77, 13.41, 14.25, 19.64,

8.37, 9.19, 19.44, 18.53, 12.04 };

public static int[] quantityArray =

{ 3, 9, 7, 8, 10, 12, 3, 6, 3, 5 };

public static double[] amountArray =
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };

// declarea decimal formatting object

static DecimalFormatdf = new DecimalFormat("###,###.##");

// the main() method is defined

public static void main(String[] args)

{

// call the method named process()

process(priceArray, quantityArray);

// call the method named display()

display(priceArray, quantityArray);

}

// define the method named process()

static void process(double[] priceA, int[] quantityA)

{

     // global arrays restored

     priceArray = priceA;

     quantityArray = quantityA;

     //looping structure to perform the multiplication

     for(count = 0; count < index; count++)

     {

     //body statement(s) for the looping structure

     }

}

// define the method named display()

static void display(double[] prices, int[] quantities)

{

     // global arrays restored

     priceArray = prices;

     quantityArray = quantities;

     // output displayed

     for(int i = 0; i< index; i++)

     {

//body statement(s) for the looping structure

     }

}

}//end the class

Thank you for the time and help.

/********************************************************************

Program Name: ArrayProcessing.java

Programmer's Name: Sammy Student

Program Description: Manipulation of three arrays ********************************************************************/

// include any necessary packages / libraries

importjava.text.DecimalFormat;

//the class file

public class ArrayProcessing

{

// declare the global variables for the array indices

public static final int index = 10;

public static int count = 0;

// declare the three arrays

public static double[] priceArray =

{ 5.73, 11.77, 13.41, 14.25, 19.64,

8.37, 9.19, 19.44, 18.53, 12.04 };

public static int[] quantityArray =

{ 3, 9, 7, 8, 10, 12, 3, 6, 3, 5 };

public static double[] amountArray =
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };

// declarea decimal formatting object

static DecimalFormatdf = new DecimalFormat("###,###.##");

// the main() method is defined

public static void main(String[] args)

{

// call the method named process()

process(priceArray, quantityArray);

// call the method named display()

display(priceArray, quantityArray);

}

// define the method named process()

static void process(double[] priceA, int[] quantityA)

{

     // global arrays restored

     priceArray = priceA;

     quantityArray = quantityA;

     //looping structure to perform the multiplication

     for(count = 0; count < index; count++)

     {

     //body statement(s) for the looping structure

     }

}

// define the method named display()

static void display(double[] prices, int[] quantities)

{

     // global arrays restored

     priceArray = prices;

     quantityArray = quantities;

     // output displayed

     for(int i = 0; i< index; i++)

     {

//body statement(s) for the looping structure

     }

}

}//end the class

Explanation / Answer

HI, Please find my implementation.

Please let me know in case of any issue.

//include any necessary packages / libraries

import java.text.DecimalFormat;

//the class file

public class ArrayProcessing

{

   //declare the global variables for the array indices

   public static final int index = 10;

   public static int count = 0;

   //declare the three arrays

   public static double[] priceArray =

       { 5.73, 11.77, 13.41, 14.25, 19.64,

               8.37, 9.19, 19.44, 18.53, 12.04 };

   public static int[] quantityArray =

       { 3, 9, 7, 8, 10, 12, 3, 6, 3, 5 };

   public static double[] amountArray =

       { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };

   public static char[] statusArray =

       { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };

   //declarea decimal formatting object

   static DecimalFormat df = new DecimalFormat("###,###.##");

   //the main() method is defined

   public static void main(String[] args)

   {

       //call the method named process()

       process(priceArray, quantityArray);

       //call the method named display()

       display(priceArray, quantityArray);

   }

   //define the method named process()

   static void process(double[] priceA, int[] quantityA)

   {

       // global arrays restored

       priceArray = priceA;

       quantityArray = quantityA;

       //looping structure to perform the multiplication

       for(count = 0; count < index; count++)

       {

           //body statement(s) for the looping structure

           amountArray[count] = priceArray[count]*quantityArray[count];

       }

   }

   //define the method named display()

   static void display(double[] prices, int[] quantities)

   {

       // global arrays restored

       priceArray = prices;

       quantityArray = quantities;

       System.out.println("Price Quantity Amount");

       // output displayed

       for(int i = 0; i< index; i++)

       {

           //body statement(s) for the looping structure

           System.out.println(df.format(priceArray[i])+" "+df.format(quantityArray[i])+" "+df.format(amountArray[i]));

          

       }

      

       System.out.println();

      

       for(int i = 0; i< index; i++){

           if(amountArray[i] >= 100)

               System.out.print((i+1)+")A ");

           else

               System.out.print((i+1)+")B ");

       }

      

       System.out.println();

   }

}//end the class

/*

Sample run:

Price       Quantity   Amount

5.73       3       17.19

11.77       9       105.93

13.41       7       93.87

14.25       8       114

19.64       10       196.4

8.37       12       100.44

9.19       3       27.57

19.44       6       116.64

18.53       3       55.59

12.04       5       60.2

1)B 2)A 3)B 4)A 5)A 6)A 7)B 8)A 9)B 10)B

*/