Free Essay

Java Inventory#4

In: Computers and Technology

Submitted By Bonifi999
Words 604
Pages 3
01 public class Inventory3 {
02
03 public static void main(String args []) {
04 Inventory invent = new Inventory();
05 Movie dvd;
05
07 dvd = new Movie("Movie1", 1, "IP Man", 5, 14.95);
08 invent.add(dvd);
09 dvd = new Movie("Movie2", 2, "Book Of Eli", 10, 12.99);
10 invent.add(dvd);
11 dvd = new Movie("Movie3", 3, "Man of Fire", 6, 19.99);
12 invent.add(dvd);
13 dvd = new Movie("Movie4", 4, "The Brothers Grimm", 3, 10.99);
14 invent.add(dvd);
15
16 invent.display();
17 } //end main
18
19 } // end class Inventory3
20
21
22 class DVD {
23 private int dvdItem;
24 private String dvdTitle;
25 private int dvdStock;
26 private double dvdPrice;
27
28 public DVD(int item, String title, int stock, double price) {
29 dvdItem = item;
30 dvdTitle = title;
31 dvdStock = stock;
32 dvdPrice = price;
33 } //end four-argument constructor
34
35 // set DVD Item
36 public void setDvdItem(int item) {
37 dvdItem = item;
38 } //end method set Dvd Item
39
40 //return DVD Item
41 public int getDvdItem() {
42 return dvdItem;
43 } //end method get Dvd Item
44
45 //set DVD Title
46 public void setDvdTitle(String title) {
47 dvdTitle = title;
48 } //end method set Dvd Title
49
50 //return Dvd Title
51 public String getDvdTitle() {
52 return dvdTitle;
53 } //end method get Dvd Title
54
55 public void setDvdStock(int stock) {
56 dvdStock = stock;
57 } //end method set Dvd Stock
58
59 //return dvd Stock
60 public int getDvdStock() {
61 return dvdStock;
62 } //end method get Dvd Stock
63
64 public void setDvdPrice(double price) {
65 dvdPrice = price;
66 } //end method setdvdPrice
67
68 //return DVD Price
69 public double getDvdPrice() {
70 return dvdPrice;
71 } //end method get Dvd Price
72
73 //calculate inventory value
74 public double value() {
75 return dvdPrice * dvdStock;
76 } //end method value
77
78 public String toString() {
79 return String.format("item=%3d title=%-20s units=%3d price=$%6.2f value=$%7.2f",
80 dvdItem, dvdTitle, dvdStock, dvdPrice, value());
81 }
82
83 } //end class DVD
84
85
86 class Movie extends DVD {
87 private String movieTitle;
88
89 public Movie(String title, int item, String dtitle, int stock, double price) {
90 super(item, dtitle, stock, price);
91 movieTitle = title;
92 }
93
94 public double value() {
95 double value = getDvdPrice() * getDvdStock();
96 value = 1.05 * value;
97 return value;
98 } //end method value
99
100 public String toString() {
101 String s = String.format("Movie title=%-12s", movieTitle);
102 s = s + " " + super.toString();
103 return s;
104 }
105
106 } // end class Movie class Inventory {

107 private DVD[] dvds;
108 private int count;
109
110 Inventory() {
111 dvds = new DVD[10];
112 count = 0;
113 }
114
115 public void add(DVD dvd) {
116 dvds[count] = dvd;
117 ++count;
118 sort();
119 }
120
121 public double entireValue() {
122 double value = 0;
123 for (int i = 0; i < count; i++) {
124 value = value + dvds[i].value();
125 }
126 return value;
127 }
128
129 public void sort() {
130 for (int index = 1; index < count; index++) {
131 DVD key = dvds[index];
132 int position = index;
133
134 // Shift larger values to the right
135 while (position > 0 && key.getDvdTitle().compareTo(dvds[position-1].getDvdTitle()) < 0) {
136 dvds[position] = dvds[position-1]; position--;
137 }
138 dvds[position] = key;
139 }
140 }
141
142 public void display() {
143 System.out.println("\nThe inventory contains " + count + " DVDs\n");
144 for (int i = 0; i < count; i++)
145 System.out.printf("%3d %s\n", i, dvds[i]);
146 System.out.printf("\nThe total inventory value is $%.2f\n\n", entireValue());
147 }
148
149 } // end class Inventory

Similar Documents

Premium Essay

Java

...that has made his work popular with programmers for many years. Michael Schidlowsky and Sedgewick have developed concise new Java implementations that both express the methods in a natural and direct manner and also can be used in real applications. Algorithms in Java, Third Edition, Part 5: Graph Algorithms is the second book in Sedgewick's thoroughly revised and rewritten series. The first book, Parts 1-4, addresses fundamental algorithms, data structures, sorting, and searching. A forthcoming third book will focus on strings, geometry, and a range of advanced algorithms. Each book's expanded coverage features new algorithms and implementations, enhanced descriptions and diagrams, and a wealth of new exercises for polishing skills. The natural match between Java classes and abstract data type (ADT) implementations makes the code more broadly useful and relevant for the modern object-oriented programming environment. The Web site for this book (www.cs.princeton.edu/~rs/) provides additional source code for programmers along with a variety of academic support materials for educators. Coverage includes: A complete overview of graph properties and types Diagraphs and DAGs Minimum spanning trees Shortest paths Network flows Diagrams, sample Java code, and detailed algorithm descriptions A landmark revision, Algorithms in Java, Third Edition, Part 5 provides a complete tool set for programmers to implement, debug, and use graph algorithms......

Words: 281 - Pages: 2

Premium Essay

Java

...tutorial explains the installation and usage of the Java programming language. It also contains examples for standard programming tasks. 1. Introduction to Java 1.1. History Java is a programming language created by James Gosling from Sun Microsystems in 1991. The first publicly available version of Java (Java 1.0) was released in 1995. Over time new enhanced versions of Java have been released. The current version of Java is Java 1.7 which is also known as Java 7. From the Java programming language the Java platform evolved. The Java platform allows that the program code is written in other languages than the Java programming language and still runs on the Java virtual machine. 1.2. Java Virtual machine The Java virtual machine (JVM) is a software implementation of a computer that executes programs like a real machine. The Java virtual machine is written specifically for a specific operating system, e.g. for Linux a special implementation is required as well as for Windows. Java programs are compiled by the Java compiler into so-called bytecode. The Java virtual machine interprets this bytecode and executes the Java program. 1.3. Java Runtime Environment vs. Java Development Kit Java comes in two flavors, the Java Runtime Environment (JRE) and the Java Development Kit (JDK). The Java runtime environment (JRE) consists of the JVM and the Java class libraries and contains the necessary functionality to start Java programs. The JDK contains in......

Words: 662 - Pages: 3

Free Essay

Java

...JAVA: Cost cutting may not be the long-term EPS driver Sun Microsystems, Inc. (JAVA) continues with its resurrection of earnings by treading into positive turf and achieving an operating profit in FY07, the first time since FY01. JAVA recorded three consecutive quarters of positive EPS in FY07 and is now targeting an operating margin of at least 10% in FY09. However, underlying this growth is a scenario that bristles with complexities, and not everything is as rosy as it seems. For instance, growth appears anemic—sales are expected to rise in low single digits this quarter. And it’s not yet clear whether JAVA is making new money through open source or simply finding new ways to save money. All eyes are now on Jonathan I. Schwartz, who took over as CEO of JAVA from Scott McNealy in Apr-06; justifiably so, because Schwartz is not merely seeking to turn around operations by paring payrolls, reducing headcount, and restructuring. He has set out to redefine the way a company can do business in the new Web age. If Schwartz can reestablish Java as a credible trendsetter, it would make for one of the Valley’s more spectacular comebacks. We analyze whether Schwartz’s pronouncements of growth objectives match JAVA’s performance across sectors and whether the targets can be achieved by cost containment rather than revenue growth. We set out to gauge whether this turnaround is a temporary blip or a true resurgence. Management change and new objectives When Schwartz took over...

Words: 1427 - Pages: 6

Free Essay

Java

...Spiral.java | Spira mirabilis | – | 3.2.6 | Complex.java | complex number data type | – | 3.2.7 | Mandelbrot.java | Mandelbrot set | – | 3.2.8 | StockAccount.java | stock account data type | Turing.txt   | 3.3.1 | Complex.java | Complex numbers (revisited) | – | 3.3.2 | Counter.java | counter data type | – | 3.3.3 | Vector.java | spatial vector data type | – | 3.3.4 | Document.java | document data type | genomeA.txt   | 3.3.5 | CompareAll.java | Similarity detection | Constitution.txt  TomSawyer.txt HuckFinn.txt  Prejudice.txt  Picture.java DJIA.csv  Amazon.html  ACTG.txt   | 3.4.1 | Body.java | gravitational body data type | – | 3.4.2 | Universe.java | N-body simulation | 2body.txt  3body.txt  4body.txt 2bodyTiny.txt   | 4 | DATA STRUCTURES | DATA | 4.1.1 | ThreeSum.java | 3-sum problem | 8ints.txt  1Kints.txt  4Kints.txt  8Kints.txt   | 4.1.2 | DoublingTest.java | validating a doubling hypothesis | – | 4.2.1 | TwentyQuestions.java | binary search (20 questions) | – | 4.2.2 | Gaussian.java | bisection search (function inversion) | – | 4.2.3 | BinarySearch.java | binary search (sorted array) | test.txt  whitelist.txt   | 4.2.4 | Insertion.java | insertion sort | tiny.txt  TomSawyer.txt   | 4.2.5 | InsertionTest.java | doubling test for insertion sort | – | 4.2.6 | Merge.java | mergesort | tiny.txt   | 4.2.7 | FrequencyCount.java | frequency counts | Leipzig100K.txt   | 4.2.8 | LRS.java | longest repeated substring |......

Words: 1619 - Pages: 7

Premium Essay

Java

...Mohammad Doush Mr. Matthew Robert English 103 13 April 2013 Java the Programming Language Computer is very important in our live, we use computer in everywhere on our live. The doctor uses the computer to see file or pictures of his patients. Also, each engineer uses it in many ways of his work. The teacher in the classroom, employees in the offices and student in their study all of them use computer in them daily live. They are not using the mouse, the keyboard or the scream. They are using the applications by them these applications in the computer are like the soul in the body. The only way to build these applications is programming. To program we need to know one of the programming languages which are very similar each other. If you are professional in one of these languages you can be professional in the other language in a short period of time. It is acceptable if you have the same application written with Java once and with C++ or C sharp at the same time. So for this reason you cannot say that a programming language is better than others. There are three types of programming languages procedural, functional and object-oriented languages. The most uses of these languages are object-oriented and one of these languages is Java you can write any application you need using it. Also you can translate any application to its word. The message of the High-Level programming languages such as Algol and Pascal in first programming revolution was...

Words: 2352 - Pages: 10

Premium Essay

Inventory Method Aca1 Task 4

...8/27/14 Re:        Inventory Method Recommendation After calculating your ending inventory values using the Periodic and perpetual FIFO, Periodic average, and Perpetual LIFO methods, the following conclusions can be made. To calculate the Periodic FIFO ending inventory value, the total number of units sold is subtracted from the total number of units on hand at the beginning of the period plus the total number of units purchased during the period. This gives us an ending inventory of 900 units. Since this calculation is First In First Out, the 900 units are valued at the cost of the last shipment (1750 units at $58.25 each) and have an ending value of $52425.00 To calculate the Periodic Average ending inventory value, the number of items left at the end of the period is multiplied by the average cost. The average cost is found by taking the total cost of the items on hand at the beginning of the period plus the total cost of items purchased during the period and dividing that total by the total of the number of items on hand at the beginning of the period plus the total number of items purchased during the period. The 900 remaining items are then multiplied by this average cost to arrive at the ending inventory level. In this case, Average cost for the period is $631,037.50 divided by 11,675 to equal $54.05 per unit. 900 units remaining times $54.05 gives us the ending inventory total of $48,645.00. The perpetual FIFO is a little more complicated. The inventory......

Words: 588 - Pages: 3

Premium Essay

Inventory

...General Services Office Inventory System Chapter 1 THE PROBLEM AND ITS BACKGROUND Introduction Computer systems and applications are basic tools used for companies and even small businesses nowadays. In order to make the tasks easier and avoid time consuming, computer technologies are now a big help. It provides tools for the employees in every office for easy tracks of daily activities related to their jobs. The computer systems and applications we create plays a vital role to make the daily works made easier, less time and efforts, more productive and accurate especially in an establishments like school offices. Computerization is now the basic necessity for every establishment, yet there are also still using manual methods which make them outdated. The General Services Office (GSO) of Divine Word College of San Jose is one of the offices which used manual methods for keeping records and transactions which make them consume lot of time and effort to find and manage all the information they needed. The data and transactions may not 100% reliable because it is handwritten and or because of human error lack of detection. The General Services Office Inventory and Scheduling system is designed to give accurate data about the first in and first out items within the office and provide accurate information on day to day schedules and reservations of specific rooms to avoid errors and conflicts to a certain schedules. The personnel in charge for the system have a......

Words: 1865 - Pages: 8

Free Essay

Java

...Eclipse and Java for Total Beginners Tutorial Companion Document Eclipse And Java For Total Beginners Companion Tutorial Document By Mark Dexter Table of Contents Introduction........................................................................................................... .............................2 . Tutorial Target Audience.....................................................................................................................2 Tutorial Objectives..............................................................................................................................2 Why learn Java with Eclipse?.............................................................................................................3 Topics Covered...................................................................................................................................3 Tutorial Approach............................................................................................................... ................3 . Getting The Most From This Tutorial..................................................................................................3 Sample Java Application – Personal Lending Library........................................................................4 Downloading and Installing Eclipse ...................................................................................................4 Playing the Lessons...........................

Words: 7556 - Pages: 31

Free Essay

Java

...Object Oriented System Software Engineering with JAVA Coursework The coursework is 50% of the assessment for the module. Learning Outcomes Have a through knowledge of one object orientated method down to detailed design. Have the experience to implement an object oriented design in an object oriented language. Assessment Criteria IMPORTANT: This is an individual assignment, all submitted components must be your own work or appropriately accredited. The assignment is scenario based (see attached scenario). You are encouraged to make any assumptions you deem necessary when analyzing he requirements outlined in the scenario, however, these must be clearly stated in the report. Your report should address the following three tasks: Task 1: Design the system required using the UML method. Task 2: Implement the system (or part of , see Grading below) using JAVA. Task 3: Objectively evaluate your solution including an appraisal of the suitability of UML and JAVA as tools for implementing object oriented solutions. Deliverable • You should submit a hard-copy and an electronic copy of the assignment • The submission should not be longer that 40 pages including diagrams but excluding the Appendices. • Instructions on how to install and run the program should be provided in an Appendix. Grading Distinction-Grade A (70%) To achieve a Distinction, you must successfully meet all of the criteria for a Merit and Task 1 • The design is comprehensive......

Words: 1035 - Pages: 5

Free Essay

Act 300 Module 4 Cost of Ending Inventory

...MODULE 4 COST OF ENDING INVENTORY To purchase this visit following link: http://www.activitymode.com/product/act-300-module-4-cost-of-ending-inventory/ Contact us at: SUPPORT@ACTIVITYMODE.COM ACT 300 MODULE 4 COST OF ENDING INVENTORY ACT 300 MODULE 4 COST OF ENDING INVENTORY To purchase this visit following link: http://www.activitymode.com/product/act-300-module-4-cost-of-ending-inventory/ Contact us at: SUPPORT@ACTIVITYMODE.COM ACT 300 MODULE 4 COST OF ENDING INVENTORY ACT 300 MODULE 4 COST OF ENDING INVENTORY To purchase this visit following link: http://www.activitymode.com/product/act-300-module-4-cost-of-ending-inventory/ Contact us at: SUPPORT@ACTIVITYMODE.COM ACT 300 MODULE 4 COST OF ENDING INVENTORY ACT 300 MODULE 4 COST OF ENDING INVENTORY To purchase this visit following link: http://www.activitymode.com/product/act-300-module-4-cost-of-ending-inventory/ Contact us at: SUPPORT@ACTIVITYMODE.COM ACT 300 MODULE 4 COST OF ENDING INVENTORY ACT 300 MODULE 4 COST OF ENDING INVENTORY To purchase this visit following link: http://www.activitymode.com/product/act-300-module-4-cost-of-ending-inventory/ Contact us at: SUPPORT@ACTIVITYMODE.COM ACT 300 MODULE 4 COST OF ENDING INVENTORY ACT 300 MODULE 4 COST OF ENDING INVENTORY To purchase this visit following link: http://www.activitymode.com/product/act-300-module-4-cost-of-ending-inventory/ Contact us at: SUPPORT@ACTIVITYMODE.COM ACT 300 MODULE 4 COST OF ENDING......

Words: 410 - Pages: 2

Premium Essay

Java

...Software Design Introduction to the Java Programming Language Material drawn from [JDK99,Sun96,Mitchell99,Mancoridis00] Software Design (Java Tutorial) © SERG Java Features • “Write Once, Run Anywhere.” • Portability is possible because of Java virtual machine technology: – Interpreted – JIT Compilers • Similar to C++, but “cleaner”: – No pointers, typedef, preprocessor, structs, unions, multiple inheritance, goto, operator overloading, automatic coercions, free. Software Design (Java Tutorial) © SERG Java Subset for this Course • We will focus on a subset of the language that will allow us to develop a distributed application using CORBA. • Input and output will be character (terminal) based. • For detailed treatment of Java visit: – http://java.sun.com/docs/books/tutorial/index.html Software Design (Java Tutorial) © SERG Java Virtual Machine • Java programs run on a Java Virtual Machine. • Features: – – – – – Security Portability Superior dynamic resource management Resource location transparency Automatic garbage collection Software Design (Java Tutorial) © SERG The Java Environment Java Source File (*.java) Java Compiler (javac) Java Bytecode File (*.class) Java Virtual Machine (java) Software Design (Java Tutorial) © SERG Program Organization Source Files (.java) Running Application Running Applet JAVA BYTECODE COMPILER Class Files (.class) JAVA VIRTUAL MACHINE WEB BROWSER Software Design (Java Tutorial) © SERG Program Organization Standards •...

Words: 5230 - Pages: 21

Premium Essay

Case 04-4: Three Little Pigs, Inc.– Inventory Impairment

...BACKGROUND Three Little Pigs, Inc. (PIGS) is a provider of pork products. The Company produces approximately 4.1 million hogs per year; the majority of which are internally processed. However, a portion of the hogs produced are sold to outside third parties. PIGS does not have any commitments to sell live hogs to third parties and it does not hedge its live hogs through commodity futures contracts. PIGS has three major categories of hog inventory: (1) live hogs available for sale; (2) developing animals; and (3) processed pork products. Management is confident that the wholesale price of processed pork products exceeds the cost to bring such products to market. However, spot market prices charged for live hogs sold to third parties have recently declined and are currently below the Company’s cost of producing these hogs. The decline in spot market prices is due to several factors, including the capture of the Big Bad Wolf, which led to an increased supply of pork. As of the second quarter ending September 2002, futures prices for lean hogs indicate a further decline before recovering late in the fourth quarter, as illustrated below: October 2002 $29.00 November 2002 $30.00 December 2002 $33.00 January 2003 $37.00 February 2003 $42.00 March 2003 $45.00 Farmer Joe asserts that the price decline reflected above is the result of seasonality. Currently, the cost of producing a live hog is $38/cwt ($38 per 100 pounds). Therefore, live hogs available for sale are......

Words: 1282 - Pages: 6

Premium Essay

Java

...Release Team[oR] 2001 [x] java Java 2: The Complete Reference by Patrick Naughton and Herbert Schildt Osborne/McGraw-Hill © 1999, 1108 pages ISBN: 0072119764 This thorough reference reads like a helpful friend. Includes servlets, Swing, and more. Table of Contents Back Cover Synopsis by Rebecca Rohan Java 2: The Complete Reference blends the expertise found in Java 1: The Complete Reference with Java 2 topics such as "servlets" and "Swing." As before, there's help with Java Beans and migrating from C++ to Java. A special chapter gives networking basics and breaks out networking-related classes. This book helps you master techniques by doing as well as reading. Projects include a multi-player word game with attention paid to network security. The book is updated where appropriate throughout, and the rhythm of text, code, tables, and illustrations is superb. It's a valuable resource for the developer who is elbow-deep in demanding projects. Table of Contents Java 2 Preface - 7 Part l The Java Language - The Complete Reference - 4 Chapter 1 Chapter 2 Chapter 3 Chapter 4 Chapter 5 Chapter 6 Chapter 7 Chapter 8 Chapter 9 hapter 10 - The Genesis of Java - 9 - An Overview of Java - 20 - Data Types, Variables, and Arrays - 36 - Operators - 57 - Control Statements - 75 - Introducing Classes - 94 - A Closer Look at Methods and Classes - 111 - Inheritance - 134 - Packages and Interfaces - 156 - Exception Handling - 174 Chapter 11 - Multithreaded......

Words: 78285 - Pages: 314

Premium Essay

Bus644 Week 4 Assignment – Inventory Control: “Harvey Industries

...Inventory management is a core operations management activity. Good inventory management is important for the successful operation of most businesses and their supply chain. Operations, marketing, and finance have interests in good inventory management. Poor inventory management hampers operations, diminishes customer satisfaction, and increases operating costs (Stevenson, 2009, pg. 549). Inventory is a stock or store of goods. Too many companies have unsatisfactory inventory management, which sometimes is a sign that management does not recognize the importance of inventories. More often than not, though the recognition is there. What is lacking is an understanding of what needs to be done and how to do it (Stevenson, 2009, pg. 549). Harvey Industries current financial and inventory distress includes: no accountability for managing inventory issues, poor inventory record keeping of on-hand and out of stock supplies and inventory that has been used. Recommendations that would help Harvey Industries with better inventory control: First, make sure to set up an inventory control team. Their task should include inventory record maintenance that covers the stock room and assembly area and a regular inventory count. Secondly, use the A-B-C approach. In which classifies inventory items according to some measure of importance, usually annual dollar value, and then allocates control efforts accordingly. Harvey can use three classes of items they used: A......

Words: 411 - Pages: 2

Premium Essay

Java

...JMaster list of Java interview questions - 115 questions By admin | July 18, 2005 115 questions total, not for the weak. Covers everything from basics to JDBC connectivity, AWT and JSP. 1. What is the difference between procedural and object-oriented programs?- a) In procedural program, programming logic follows certain procedures and the instructions are executed one after another. In OOP program, unit of program is object, which is nothing but combination of data and code. b) In procedural program, data is exposed to the whole program whereas in OOPs program, it is accessible with in the object and which in turn assures the security of the code. 2. What are Encapsulation, Inheritance and Polymorphism?- Encapsulation is the mechanism that binds together code and data it manipulates and keeps both safe from outside interference and misuse. Inheritance is the process by which one object acquires the properties of another object. Polymorphism is the feature that allows one interface to be used for general class actions. 3. What is the difference between Assignment and Initialization?- Assignment can be done as many times as desired whereas initialization can be done only once. 4. What is OOPs?- Object oriented programming organizes a program around its data, i. e. , objects and a set of well defined interfaces to that data. An object-oriented program can be characterized as data controlling 5. access to code. What are Class,......

Words: 6762 - Pages: 28