help me about linked list plss

how to do a calculation in linked list

Page 1 of 1

5 Replies - 2451 Views - Last Post: 15 September 2008 - 03:04 PM Rate Topic: -----

#1 Hadry   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 15-September 08

help me about linked list plss

Posted 15 September 2008 - 02:12 PM

Linked List

Given the following Invoice and LinkedList ADTs:

public class Invoice
{
private int orderID;
private String custName;
private String prodName;
private int prodQuantity;
private double unitPrice;

public Invoice() {}
public void setData(int oid, String cn, String pn, int pq
double up) {}
public int getOrderID() {}
public String getCustName() {}
public String getProdName() {}
public int getProdQuantity(){}
public double getUnitPrice(){}

}

public class LinkedList
{
public void insert(Object elem){}
//insert elemen into list

public Object remove(){}
//remove elemen from list

public boolean isEmpty() {}
//return true if list is empty

//definition for other methods
}


Write a Java application to solve the following problems:

a) Input 10 invoices into a linked list. (4 marks)

B) Display the information of invoice that makes the highest payment. The payment is calculated by multiplying progQuality and unitPrice. At the end of the process, the information of all invoices must remain in the original linked list.
(6 marks)

c) Count the number of invoices where the payment is more than RM5000, and also display the information of those invoices.
(4 marks)


guys,can u give me tips on this question...this is just my revision study..

Is This A Good Question/Topic? 0
  • +

Replies To: help me about linked list plss

#2 Hadry   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 15-September 08

Re: help me about linked list plss

Posted 15 September 2008 - 02:13 PM

Linked List

Given the following Invoice and LinkedList ADTs:

public class Invoice
{
private int orderID;
private String custName;
private String prodName;
private int prodQuantity;
private double unitPrice;

public Invoice() {}
public void setData(int oid, String cn, String pn, int pq
double up) {}
public int getOrderID() {}
public String getCustName() {}
public String getProdName() {}
public int getProdQuantity(){}
public double getUnitPrice(){}

}

public class LinkedList
{
public void insert(Object elem){}
//insert elemen into list

public Object remove(){}
//remove elemen from list

public boolean isEmpty() {}
//return true if list is empty

//definition for other methods
}


Write a Java application to solve the following problems:

a) Input 10 invoices into a linked list. (4 marks)

B) Display the information of invoice that makes the highest payment. The payment is calculated by multiplying progQuality and unitPrice. At the end of the process, the information of all invoices must remain in the original linked list.
(6 marks)

c) Count the number of invoices where the payment is more than RM5000, and also display the information of those invoices.
(4 marks)


guys,can u give me tips on this question...this is just my revision study..
Was This Post Helpful? 0
  • +
  • -

#3 nick2price   User is offline

  • D.I.C Lover
  • member icon

Reputation: 565
  • View blog
  • Posts: 2,826
  • Joined: 23-November 07

Re: help me about linked list plss

Posted 15 September 2008 - 02:16 PM

Carry on posting the same topic and i am sure no-one will help you.
Was This Post Helpful? 0
  • +
  • -

#4 Hadry   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 15-September 08

Re: help me about linked list plss

Posted 15 September 2008 - 02:28 PM

View Postnick2price, on 15 Sep, 2008 - 02:16 PM, said:

Carry on posting the same topic and i am sure no-one will help you.

owh...sorry...just click too many..didnt realize it..can u help me?
Was This Post Helpful? 0
  • +
  • -

#5 nick2price   User is offline

  • D.I.C Lover
  • member icon

Reputation: 565
  • View blog
  • Posts: 2,826
  • Joined: 23-November 07

Re: help me about linked list plss

Posted 15 September 2008 - 02:46 PM

If you mean by help, do it for me, then the answer is no. You have to attempt the code yourself and people on here will guide you along, but you need to make the effort.
Start of with a) Input 10 invoices into a linked list. (4 marks)

Create a linked List
input invoice, which i cant see the method for unless you have to create it. If the input is just a single item, just use a scanner or inputDialog to ask the user to enter the invoice amount, and make it loop 10 times.

On every loop, add the input to your list. If you search the internet, you will see many examples of how linkedList work. Try somthing then post back.
Was This Post Helpful? 0
  • +
  • -

#6 Hadry   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 15-September 08

Re: help me about linked list plss

Posted 15 September 2008 - 03:04 PM

View Postnick2price, on 15 Sep, 2008 - 02:46 PM, said:

If you mean by help, do it for me, then the answer is no. You have to attempt the code yourself and people on here will guide you along, but you need to make the effort.
Start of with a) Input 10 invoices into a linked list. (4 marks)

Create a linked List
input invoice, which i cant see the method for unless you have to create it. If the input is just a single item, just use a scanner or inputDialog to ask the user to enter the invoice amount, and make it loop 10 times.

On every loop, add the input to your list. If you search the internet, you will see many examples of how linkedList work. Try somthing then post back.



here what i got..

import javax.swing.JOptionPane;

public class InvoiceApp {
public static void main( String args[] )
{
LinkedList objList = new LinkedList(); // create the List container

// Create objects to store into the List
String num = JOptionPane.showInputDialog("Please enter number of Invoice");
int numInv = Integer.parseInt(num);
for (int i=0; i < numInv; i++)
{
String aorderID = JOptionPane.showInputDialog("Order Id : ");
String acustName = JOptionPane.showInputDialog("Customer Name :");
String aprodName = JOptionPane.showInputDialog("Product name :");
String aprodQuantity = JOptionPane.showInputDialog("Product quantity :");
String aunitPrice = JOptionPane.showInputDialog("Unit price : ");
int orderID = Integer.parseInt(aorderID);
int prodQuantity = Integer.parseInt(aprodQuantity);
double unitPrice = Double.parseDouble (aunitPrice);
Invoice Inv = new Invoice (orderID, acustName, aprodName, prodQuantity, unitPrice);
objList.insertFirst(Inv);
}


// display the contents of the linked list
objList.print();

Invoice removedNode;
removedNode = (Invoice)objList.removeFirst();
System.out.println("\n Removed node :" + removedNode.toString());
objList.print();

}
}
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1