ADoyle4

Untitled

Mar 6th, 2012
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. class Item{
  2.  
  3. private String name;
  4. private int num;
  5. private double price;
  6.  
  7. void put(){
  8. System.out.print("Enter name, Quantity of stock, and price respectively: ");
  9. name = Console.readToken();
  10. num = Console.readInt();
  11. price = Console.readDouble();
  12. }
  13.  
  14. double value(){
  15. return (double)(num*price);
  16. }
  17.  
  18.  
  19.  
  20.  
  21. public static void main(String [] args){
  22. Item a = new Item();
  23. a.put();
  24. Item b = new Item();
  25. b.put();
  26. System.out.println(a.value());
  27.  
  28. if(a.value()>b.value()){
  29. System.out.println("the first item has the larger stock value which is " + a.value());
  30. }
  31. else{
  32. System.out.println("the second item has the larger stock value which is " + b.value());
  33. }
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment