All code will be in Java, and there will be TWO source code.
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 processOrderof this class. Inside method processOrder, 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 10012. Row 0 of the array for the unit price is to hold the unit price of product 10012. Row 0 of the array for the current inventory level is to hold the current inventory level of product 10012, etc.
The system should accept one incoming sales order. In this sales order, the 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. 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:
Please enter the next product number to buy or -99 = end:<user enters a product number or -99>
You can assume that the user will enter an integer value.
{
(b)ask for the quantity ordered, “Enter quantity ordered:”<user enters the quantity 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: <the quantity that can be sold>”
Calculate the amount for this item as Unit Price * Quantity Sold.
Display the amount for this item: “Item Amount: $ <the amount
calculated>”
Add this amount to the current order total amount.
Since this item has been sold, update the current inventory level of this
item.
Else this means inventory level is 0: display “This item is out of stock. Please pick another one.”
Else this product is not found, display an error message “Invalid product number.”
Please enter the next product number to buy or -99 = end):<user enters a product number or -99>
You can assume that the user will enter an integer value.
} // end of the while loop
Order Total Amount: $ 72.83
II. Write the class MailOrderTest to provide the following functions:
In method mainof this application, instantiate an object of MailOrderand call the method processOrderof this MailOrderobject to start order processing.
DO NOT USE Until loop (the “do-while” loop in Java)
class MailOrder
{
public processOrder()
{
int[] product_number={10011, 10012, 10013, 10014, 10015};
float[] unit_price={10.5, 11.2, 20.4, 30, 25};
int[] inventory_level={10, 20, 30, 40,50};
double total_amt=0;
double final_amt=0
Scanner myObj = new Scanner(System.in); // Create a
Scanner object
System.out.println("Please enter
the next product number to buy or -99 = end");
int no = myObj.nextInt(); //
Read user input
while(no !=-99)
{
for(int i=0;i<product_number.length;i++)
{
if(product_number[i] == no)
{
if(inventory_level>0)
{
System.out.println("current inventory level is"+inventory_level[i]);
System.out.println("unit price is"+unit_pricel[i]);
System.out.println("Enter quatity of that product");
int quantity = myObj.nextInt();
if(quantity<= inventory_level[i] )
{
System.out.println("product sold as per your requirement"+ quantity);
total_amt=quantity*unit_price;
System.out.println("Total amount will be"+ total_amt);
System.out.println("Remaining quantity is"+ inventory_level[i]-quantity);
final_amt=final_amt+total_amt;
System.out.println("Final amount will be"+ final_amt);
}
else
{
System.out.println("we can sell only what we have "+ inventory_level[i]);
total_amt=inventory_level[i]*unit_price;
System.out.println("Total amount will be"+ total_amt);
System.out.println("now product is out of stock please pick another one");
final_amt=final_amt+total_amt;
System.out.println("Final amount will be"+ final_amt);
}
}
}
else{System.out.println("This product is not available ");}
System.out.println("Please enter the next product number to buy or -99 = end");
}//end of while loop
System.out.println("Total amout of all product is"+final_amt);
System.out.println("Bye");
}
}
public class MailOrderTest
{
public static void main(String args[])
{
MailOrder m = new MailOrder();
m.processOrder();
}
}
All code will be in Java, and there will be TWO source code. I. Write the...
Write a Java application that prompts the user for pairs of inputs of a product number (1-5), and then an integer quantity of units sold (this is two separate prompts for input values). You must use a switch statement and a sentinel-controlled loop (i.e. a loop that stops execution when an out of range value, such as -1, is input). All 15 items below are for a single purchase. There are five sets of inputs as follows: Product 1 1...
java programe
Write a program that prompts the user to enter in an integer number representing the number of elements in an integer array. Create the array and prompt the user to enter in values for each element using a for loop. When the array is full, display the following: The values in the array on a single line. The array with all of the elements reversed. The values from the array that have even numbered values. The values from...
What is the java code for this.
The goal of this lab is to write two programs, Summation and Prime, that execute simple tasks. The first computes the summation of integers within a range with a gap that the user specifies. The second tests whether the integer that the user enters is a square and if not, whether it is composite or prime. Summation Let us see some execution examples first, to get the sense of how the program works....
Write in C# Programming Language. - count =0; - Create a 2d array "items". string[,] items = new string[100, 4]; - Create a do while loop, when user enter "0", stop the loop. - User enter item name, price, quantity, save these info and subtotal to array. - increase "count++" -conver price(decimal, Convert.ToDecimal() ) and quantity(int) to do mulplication for subtotal - create a for loop (with count ) to cycle through the "items", display item name, price, quantity, and...
Create a class named Invoice that contains fields for an item number, name, quantity, price, and total cost. Create insurance methods that set the item name, quantity,and price. Whenever the price for quantity is set, recalculate the total (price times quantity). Also include a display Line() method that displays the item number,name, quantity, price, and total cost. Make sure you include a class named TestInvoice whose main method () declares three Invoice items. Create a method that prompts the user...
I need to Write a test program that prompts the user to enter 10 double values into an array, calls a method to calculate the average of the numbers, and displays the average. Next, write a method that returns the lowest value in the array and display the lowest number. The program should then prompt the user to enter 10 integer values into an array, calculates the average, and displays the average. The program should have two overloaded methods to...
Your assignment is to create a restaurant ordering system where
the cashier can create the menu and then take in the order and
display the order back to the customer
Sample Execution – Level 1
Welcome to your Menu Creation system.
How many items would you like to have on your menu? 2
Create your menu!
Enter item #1: Coffee
Enter item #2: Tea
This is the menu:
Coffee
Tea
What would you like to order? Cake
That isn’t on...
An online company sells hundreds of office supply products on
its e-Commerce store. It has asked you to design and implement a
sales order processing system which will be used by users in our
Operations department to process sales orders. Here is an overview
of the sales order process. Customers make purchases by placing
orders. Each customer has a customer number and profile (such as
name, shipping address). To simplify the matter, each time an order
is placed, only one...
I need help building code in python for this: Create a program that: Creates a sales receipt, displays the receipt entries and totals, and saves the receipt entries to a file Prompt the user to enter the Item Name Item Quantity Item Price Display the item name, the quantity, and item price, and the extended price (Item Quantity multiplied by Item Price) after the entry is made Save the item name, quantity, item price, and extended price to a file...
1. (Sum the digits in an integer) Write a method that computes the sum of the digits in an integer. Use the following method header: public static int sumDigits(long n) For example, sumDigits (234) returns 9 (2 + 3 + 4). (Hint: Use the % operator to extract digits, and the / operator to remove the extracted digit. For instance, to extract 4 from 234, use 234 % 10(= 4). To remove 4 from 234, use 234 / 10(= 23)....