I need a Java program that handles the order list for if I were an online retailer. The program should contain a minimum of three classes:
Order Class
Display Class
Main Class
The Order Class that uses a queue to hold the orders in the order they were taken, and the queue should contain the customer's last name, order number, and order total cost. The Display Class needs to store a copy of the order queue in two arrays. Each array will contain the order list, but one will be sorted by name and the other sorted by order number. When an order is taken and stored in the Order Class the program will update the Display Class arrays automatically and sort them in descending order using quick sort and outputs the contents to the console upon each entry of new data.


There should be a Main Class that will handle operator data input and when an order is added or removed, the program will update the Order Class and Display Class. The end-user should be presented with a menu to add an order, remove an order and display the order list from the queue.

Answers

Answer 1

Using the knowledge in computational language in JAVA it is possible to write a code that  handles the order list for if I were an online retailer.

Writting the code:

import java.lang.*;

import java.util.*;

class Fruit{

private String fruit_name;

private double tot_weights;

private double price;

public const static String fruit_nvalue="?";

public const static double def_value=0.0;

public Fruit(){

 fruit_name=fruit_nvalue;

 tot_weights=price=def_value;

}

public Fruit(String fruit_name,double tot_weights,double price){

 this.fruit_name=fruit_name;

 this.tot_weights=tot_weights;

 this.price=price;

}

public double order(double order_weights){

 if(order_weights>tot_weights){

  return double(-1);

 }

 else{

  tot_weights=tot_weights - order_weights;

  return order_weights*price;

 }

}

public Boolean equals(String fruit1,double wei1,double price1,String fruit2,double wei2,double price2){

 if(((fruit1.equals(fruit2)) &&(wei1==wei2) && (price1==price2))== true ){

  return true

 }

}

public String toString(){

 return fruit_name+" "+tot_weights+" "+price;

}

}

class OnlineSuperMarket{

private Fruit[] fruit_objects;

private String store_name;

private String web_address;

public const static float tax_rate = 0.095;

public const static int size=10;

public const static sn="TBD";

public const static wa="www.unknown.com";

Scanner scan=new Scanner(System.in);

public OnlineSuperMarket(){

 fruit_objects=new Fruit[size];

 store_name = sn;

 web_address = wa;

}

public OnlineSuperMarket(String store_name,String web_address){

 this.store_name=store_name;

 this.web_address=web_address;

 fruit_objects=new Fruit[size];

}

public void init(){

 String fruit_names[];

 double weights[];

 double prices[];

 

 for(int i=0;i<fruit_objects.length;i++){

  fruit_objects[i]=new Fruit(scan.next(),scan.nextDouble(),scan.nextDouble());

 }

}

public void sort(){

 Arrays.sort(fruit_objects);

}

public void run(){

 while(true){

  System.out.println(" Enter a fruit name or Q (or q) to end:");

  String choice= scan.next();

  if(choice = "Q" || choice = "q"){

   quit();

  }

  else{

   if(find(choice)){

    System.out.println("Enter weight in lbs:");

    double weight=new nextDouble();

    double price = order(weight);

    if(price == double(-1)){

     System.out.println("quantity not available");

    }

    else{

     total_cost = price+tax_rate;

     System.out.println("You ordered");

     System.out.println("Fruit: "+choice);

     System.out.println("Weight: "+weight+" lbs");

     System.out.println("Price: "+price+"/lbs");

     System.out.println("Total cost (plus tax): $"+total_cost);

    }

   }

   else{

    System.out.println(choice+" not available");

   }

  }

 }

}

public void showFruits(){

 for(Fruit obj:fruit_objects){

  System.out.println(obj.toString());

 }

}

public void quit(){

 showFruits();

 System.out.println("Thanks for your visit. Please come again!");

 System.exit();

}

public Boolean find(Strign fruit_name){

 sort();

 int first=0;

 int last = fruit_objects.length;

 int mid = (first + last)/2;  

    while( first <= last ){  

       if (fruit_objects[mid] < fruit_name ){  

         first = mid + 1;    

       }else if ( fruit_objects[mid].equals(fruit_name) ){  

         return true;  

         break;  

       }else{  

          last = mid - 1;  

       }  

       mid = (first + last)/2;  

    }  

    if ( first > last ){  

       return false;

    }  

}

}

public class Design{

public static void main(String[] args) {

 OnlineSuperMarket osm=null;

 osm = new OnlineSuperMarket(store_name, web_address);

 init();

 showFruits();

 sort();

 showFruits();

}

}

See more about JAVA at brainly.com/question/12975450

#SPJ1

I Need A Java Program That Handles The Order List For If I Were An Online Retailer. The Program Should
I Need A Java Program That Handles The Order List For If I Were An Online Retailer. The Program Should
I Need A Java Program That Handles The Order List For If I Were An Online Retailer. The Program Should

Related Questions

Suppose that you have created a program with only the following variables
Int age=34
Int weight =180
Double height =5.9
Suppose that you also have a method with the following header:
Public static void calculate (Int age, double size)

Which of the following methods calls are legal and why
Calculate (age, height)
Calculate (weight, weight)

Answers

Explanation:

Calculate (age, height) is legal because method's second argument (double size), needs double value.

what coder does assembly language use for programming?

Answers

Answer:

These short codes are converted into machine learning language (binary, i.e., 1s and 0s) through the use of programs called assemblers. In a nutshell, machine language uses binary code, which is almost impossible for humans to decipher, whereas assembly language uses mnemonic codes to write a program.

Please help me this goes with computer science so yeah

Answers

In today's world, the electronic version of the above can be sent as an ecard via any standard email service provider instantly over the internet.

How can the sender and receiver achieve the above?

In order for the above to be possible today, the sender must have have an electronic mail address which is referenced to a domain name. The same goes to the receiver.

It is to be noted that the data (in this case the text and pictures contained int he postcard) are delivered to user accounts across several computer servers.

The computer servers transport the messages to their final destination and store them so that users may retrieve and send them whenever they connect to the email infrastructure. An email client or a web interface can be used to access email.

What are the comparisons?

While there is a feeling that comes with handling physical mail such as the advantage of having the card retrieved without electricity, the ability to create handcrafted art, and even perfumed cards, they took relatively too long to prepare and to be sent to receiver.

Unlike traditional mail, electronic postcards are can be created, customized and sent withing a minute. E-post cards, unlike traditional ones, can be automated and sent to million of people at the same time in an instant.

Learn more about postcards:
https://brainly.com/question/15435088
#SPJ1

Other Questions
rebecca received the following e-mail from her boss: i need all employees to work late on saturday. no exceptions! what is the most likely reason why this communication is not effective? rebecca may not want to work on saturday. the e-mail does not explain the reasons why the employees must work late. the use of capital letters may make rebecca feel like her boss is yelling at her. rebecca may not check her e-mail until after saturday Help if u can you will get brainlest 11 and 12 same answers for the questions an upward force of 170 N IS APPLIED TO A BOX WEIGHING 50 N DRAW A FREEBODY FORCE DIAGRAM FOR THIS SITUATION A kindergarten teacher is having students listen to three spoken words and identify the two words that end with the same sound. The teacher is focusing on which language system? What is the most prominent figurative language element in this excerpt from the poem The First Snowfall by James Russell Lowell?Every pine and fir and hemlockWore ermine too dear for an earl, And the poorest twig on the elm-treeWas ridged inch deep with pearl. determine which action was supported by both eisenhower's new look foreign policy and kennedy's flexible response foreign policy. african societies have rich artistic culture. in addition to music, dance, sculpture, weaving, and literature, many african societies have talented, professional storytellers. these oral historians called serve religious, familial, and societal roles. a. bantus c. nzingas b. griots d. benues please select the best answer from the choices provided a b c d becky and alex need to decide which one of them will take time off from work to complete the rather urgent task of shearing their llamas. becky is pretty good with a pair of shears; she can shear the llamas in 30 minutes. alex is somewhat slow; it takes him 5 hours to shear the llamas. becky earns $160 per hour as a lawyer, while alex earns $20 per hour as a barber. keeping in mind that either becky or alex must take time off from work to shear the llamas, who has the lowest opportunity cost of completing the task? Summary of the climate in Houston, Texas a chemist measured the amount of rubidium chloride produced during an experiment. she finds that of rubidium chloride is produced. calculate the number of moles of rubidium chloride produced. Evaluate 15 6(7 + 5) 32. Find a relationship between x and y so that (x, y) is equidistant from the two points (4, 1) and (6, 3). **40-POINTS**Write a comprehensive two-paragraph essay on why, where, when, and how Islam developed and spread; begin with the year 632 CE (death of the Prophet Muhammad) and conclude with the state of present day Islam. As the world population grows, so will the demand for more resources and consumer goods. What do you thinkwill happen to the price of resources that are in limited supply, such as gasoline or some types of metal? Whatmight individuals, businesses, and governments do to try to raise people's standard of living while keeping pricesat reasonable (and affordable) levels? explain why cooking food with pressure pot is faster than cooking with an ordinary pot A bag contains 3 redmarbles, 5 blue marbles and 4 green marbles. If three marblesare drawn out of the bag, what is the exact probability that all three marbles drawnwill be blue?Can yall help me please?? To what extent did women of the upper classes experience a Renaissance? when the employer pays some or all of the cost of health insurance for its employees, the benefits paid to each employee are a client with acute myeloid leukemia has a fever. what pathophysiological process does the nurse recognize is the cause of the client's fever? increases in equity of a particular business enterprise resulting from transfers to it from other entities of something of value to obtain or increase ownership interests is a(n)