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

I need help writing an aplication in java that does the following: has to use ar

ID: 3627298 • Letter: I

Question

I need help writing an aplication in java that does the following:

has to use arrays and while loops (no do-while loops)



MP Mail Order House sells five products. Product numbers, unit prices, and current inventory levels, are as
follows:
Product Number Unit Price Current Inventory Level
1001 $2.98 10
1002 $4.50 8
1003 $9.98 15
1004 $4.49 3
1005 $6.87 0

I. Write the class MailOrder to provide the following functions:
At this point of the class, since we have not gone through object-oriented programming and method calling in detail yet, the basic requirement in this homework is process-oriented programming with all the code inside
method processOrders of this class. Inside method processOrders, we still follow the principles of
structured programming.
Set up one one-dimensional array for each field: product number (integer), unit price (double), and current
inventory level (integer) in main memory to hold the above product information. There should be five rows (0 to
4) in each array, one for each item. For example, row 0 of the array for the product number is to hold the product
number of product 1001. Row 0 of the array for the unit price is to hold the unit price of product 1001. Row 0
of the array for the current inventory level is to hold the current inventory level of product 1001, etc.
The system should accept incoming sales orders until the user chooses to quit. In each sales order, a user can
buy more than one item. For each item, the system accepts the product number and the quantity to be
purchased. The system retrieves the correct unit price and current inventory level for that particular item. The
system only sells up to the current inventory available. If the system can sell x pieces of this item in this order,
the system calculates and displays the total amount for this item and also decreases the item inventory level by x
immediately. When the user has finished keying in all the items of an order, the system displays the order total
amount.
When the user says there are no more orders, the system displays the total sales amount of the day. This is the
total sales amount of all the orders processed. Then the system should end the execution of the system.
Detailed description of how the system should work is as follows:
When execution of the system is started:
Set up and correctly initialize all variables
Display the following main question:
Please enter the next action (1=Enter a new order and 2=Bye):
You can assume the value a user enters is an integer value. If the user enters any integer value other than 1 and 2, keep displaying the above question until the user has entered either 1 or 2. If the user enters an integer value
that is not 1 and not 2, then the system displays an error message and prompts the user again.

If the user chooses entering a new order (1), then (a) clear the current order total amount for this upcoming new
order and (b) display the next product number question:
• Please enter the next product number to buy (1001 – 1005 or -99 = end): 1003, 1004, 1005 or -99>
You can assume that the user will enter an integer value. If the user enters an integer value that is not
one of -99, 1001, 1002, 1003, 1004, and 1005, then repeat this question again until the user has entered
one of the acceptable values.
o If user enters -99, this means the end of the current order:
• Display order summary, for example:
Order Total Amount: $ 72.83
• Add this order total amount to the daily sales total amount.
• The system should go back to asking the main question, as shown above.
o If the user enters 1001, 1002, 1003, 1004, or 1005 (these are product numbers), this is the next
item to be purchased:
• If the current inventory level of this product is 0, display “This item is out of stock. Please
pick another one.” The system goes back to asking for the next product number, as shown
above.
• If the current inventory level is > 0, (a) display “Unit Price: “
and “Current Quantity Available: ” and (b)
ask for the quantity ordered, “Enter quantity ordered: ” ordered>.
You can assume that the user will key in a positive integer value.
If the quantity available is smaller than the quantity ordered, sell only the quantity available.
Otherwise, sell the ordered quantity.
Display “Quantity Sold: ”
Calculate the amount for this item as Unit Price * Quantity Sold.
Display the amount for this item: “Item Amount: $ ”
Add this amount to the current order total amount.
Since this item has been sold, update the current inventory level of this item.
Repeat the above until the user enters -99 for the next product number to buy.
When the user enters a -99 for the next product number, the system (a) displays the total amount of this
order and (2) add the current order total amount to the total sales amount of the day.
Then the system displays the main question again and repeats the above until the user enters a choice
value of 2 (Bye).

If the user chooses ending the whole order entry operation (2), then the system displays the total sales amount of the day and ends the execution.

Explanation / Answer

please rate - thanks

import java.util.*;
public class MailOrder
{
public static void main(String[] args)
{processOrders();
}
public static void processOrders()
{Scanner in=new Scanner(System.in);
int prodNumber[]={1001,1002,1003,1004,1005};
double price[]={2.98,4.5,9.98,4.49,6.87};
int current[]={10,8,15,3,0};
int n,num,q,i,j;
double totalSales=0,tot=0,sold;
System.out.print("Please enter the next action (1=Enter a new order and 2=Bye): ");
n=in.nextInt();
while(n!=2)
   {if(n==1)
        {tot=0;
        System.out.print("Please enter the next product number to buy (1001 – 1005 or -99 = end): ");
        num=in.nextInt();
        while(num!=-99)
             {i=-1;
               for(j=0;j<5;j++)
                   if(prodNumber[j]==num)
                           i=j;
                         
            if(i!=-1)
                  {if(current[i]==0)
                         System.out.println("This item is out of stock. Please pick another one.");
                    else
                        {System.out.printf("Item #: %d unit price: $%.2f Current Quantity Available: %d ",num,price[i],current[i]);
                            System.out.print("Enter quantity ordered: ");
                            q=in.nextInt();
                            if(q>current[i])
                                q=current[i];
                            sold=q*price[i];
                            tot+=sold;
                            System.out.printf("Quantity Sold: %d item Amount: $%.2f ",q,sold);
                            current[i]-=q;

                                                   
                        }   

                   
                    }
                else
                   System.out.println("Invalid entry");
            System.out.print("Please enter the next product number to buy (1001 – 1005 or -99 = end): ");
             num=in.nextInt();

            }
        System.out.printf("Order Total Amount: $%.2f ",tot);
        System.out.println();
        totalSales+=tot;
        }
    else
         System.out.println("Invalid entry");
    System.out.print("Please enter the next action (1=Enter a new order and 2=Bye): ");
    n=in.nextInt();
    }
System.out.printf("Todays total sales: $%.2f ",totalSales);
   
    }
}