Welcome to Dream.In.Code
Become a Java Expert!

Join 150,190 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 2,049 people online right now. Registration is fast and FREE... Join Now!




help me about linked list plss

 
Reply to this topicStart new topic

help me about linked list plss, how to do a calculation in linked list

Hadry
15 Sep, 2008 - 01:12 PM
Post #1

New D.I.C Head
*

Joined: 15 Sep, 2008
Posts: 7

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)

cool.gif 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..

User is offlineProfile CardPM
+Quote Post

Hadry
RE: Help Me About Linked List Plss
15 Sep, 2008 - 01:13 PM
Post #2

New D.I.C Head
*

Joined: 15 Sep, 2008
Posts: 7

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)

cool.gif 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..

User is offlineProfile CardPM
+Quote Post

nick2price
RE: Help Me About Linked List Plss
15 Sep, 2008 - 01:16 PM
Post #3

D.I.C Regular
***

Joined: 23 Nov, 2007
Posts: 338



Thanked: 12 times
My Contributions
Carry on posting the same topic and i am sure no-one will help you.
User is offlineProfile CardPM
+Quote Post

Hadry
RE: Help Me About Linked List Plss
15 Sep, 2008 - 01:28 PM
Post #4

New D.I.C Head
*

Joined: 15 Sep, 2008
Posts: 7

QUOTE(nick2price @ 15 Sep, 2008 - 02:16 PM) *

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?
User is offlineProfile CardPM
+Quote Post

nick2price
RE: Help Me About Linked List Plss
15 Sep, 2008 - 01:46 PM
Post #5

D.I.C Regular
***

Joined: 23 Nov, 2007
Posts: 338



Thanked: 12 times
My Contributions
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.

User is offlineProfile CardPM
+Quote Post

Hadry
RE: Help Me About Linked List Plss
15 Sep, 2008 - 02:04 PM
Post #6

New D.I.C Head
*

Joined: 15 Sep, 2008
Posts: 7

QUOTE(nick2price @ 15 Sep, 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.



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();

}
}
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 04:16AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Java Help!

Java Tutorials

Reference Sheets

Java Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month