Do I need that line? With the Re-Stocking Fee? I am getting so confused right now I swear I am about in tears now I only have 2 days to have this done.
package javaapplication31; import java.util.Arrays; public class Inventory3a{ Inventory3a() { // constructor Product[] dvd = new Product[4]; dvd[0] = new Product(685.0,"How to Loose a Guy in 10 days",2003, 4, 19.99 ); dvd[1] = new Product(565.0,"Coyote Ugly Ugly",2000, 8, 19.98 ); dvd[2] = new Product(785.0,"Legally Blonde",2001, 13, 19.99); dvd[3] = new Product(578.0,"Sweet Home Alabama",2002, 8,18.56); double totalInStock = 0.0; double totalValue = 0.0; double ReStockingFee= 0.0; for(int i = 0; i < 4; i++) { System.out.println("Item number: " + dvd[i].getdvdItemNumber()); System.out.println("Title: " + dvd[i].getdvdTitle()); System.out.println("Made in: "+ dvd[i].getdvdYear()); System.out.println("In Stock: " + dvd[i].getdvdStock()); System.out.println("The price of each DVD is $" + dvd[i].getdvdPrice()); System.out.println("The value of the inventory is $" + dvd[i].Calvalue()); totalInStock += dvd[i].getdvdStock(); totalValue += dvd[i].Calvalue(); System.out.println("Total In Stock:" + totalInStock + " Total Value: $" + totalValue); System.out.println("Restock Fee: " + (dvd[i].getdvdStock() * dvd[i].getdvdPrice()) * 0.05);} System.out.println(); } public static void main(String args []) { //Sorting strings String[ ] titles = {"How to Loose a Guy in 10 days", "Coyote Ugly", "Legally Blonde", "Sweet Home Alabama"}; Arrays.sort(titles); //use the built-in sorting routine for (int i = 0; i < 4; i++) System.out.println(titles[ i ]); double ReStockFee = 0.05; new Inventory3a(); } //end method main } class Product { public double dvdItemNumber; public String dvdTitle; public double dvdYear; public double dvdStock; public double dvdPrice; public double totalInStock; public double totalValue; public double ReStockFee; // five-argument constructor Product(double item,String title,double year, double stock, double price ) { dvdItemNumber = item; dvdTitle = title; dvdYear = year; dvdStock = stock; dvdPrice = price; } //end five-argument constructor // set dvd item number public void setdvdItemNumber (double item) { dvdPrice= item; }// end method setdvdItemNumber // return dvd item number public double getdvdItemNumber() { return dvdItemNumber; }// end method getdvdItemNumber // set dvd title public void setdvdTitle (String title) { dvdTitle= title; }// end method setdvdTitle // return dvd title public String getdvdTitle() { return dvdTitle; }// end method getdvdTitle // set dvd year // set dvd stock public void setdvdYear(double year) { dvdYear= year; }// return dvd year public double getdvdYear() { return dvdYear; }// end method getdvdYear // set dvd stock public void setdvdStock(double stock) { dvdStock= stock; } // end method getdvdStock // return dvd stock public double getdvdStock() { return dvdStock; }// end method getdvdStock // set dvd price public void setdvdPrice (double price) { dvdPrice= price; }// end method setdvdPrice // return dvd price public double getdvdPrice() { return dvdPrice; }// end method getdvdPrice // set total in stock public void settotalInStock (double total) { totalInStock= total; }// end method settotalInStock // return total in stock public double gettotalInStock() { return totalInStock; }// end method gettotalInStock // caluclate Inventory public double Calvalue() { return dvdPrice * dvdStock; } //end method value // calculates Total Value public double totalValue(){ return dvdPrice * totalInStock; } // end method value // calculates Re-Stocking Fee public double ReStockingFee(){ return dvdPrice * totalInStock * .05; }// end method value // returns smaller, bigger or equals according to dvdTitle public int compareTo(Object o){ Product other = (Product) o; return dvdTitle.compareTo(other.dvdTitle); } } // end Product Class
package javaapplication31; import java.util.Arrays; public class Inventory3a{ Inventory3a() { // constructor Product[] dvd = new Product[4]; dvd[0] = new Product(685.0,"How to Loose a Guy in 10 days",2003, 4, 19.99 ); dvd[1] = new Product(565.0,"Coyote Ugly Ugly",2000, 8, 19.98 ); dvd[2] = new Product(785.0,"Legally Blonde",2001, 13, 19.99); dvd[3] = new Product(578.0,"Sweet Home Alabama",2002, 8,18.56); double totalInStock = 0.0; double totalValue = 0.0; double ReStockingFee= 0.0; for(int i = 0; i < 4; i++) { System.out.println("Item number: " + dvd[i].getdvdItemNumber()); System.out.println("Title: " + dvd[i].getdvdTitle()); System.out.println("Made in: "+ dvd[i].getdvdYear()); System.out.println("In Stock: " + dvd[i].getdvdStock()); System.out.println("The price of each DVD is $" + dvd[i].getdvdPrice()); System.out.println("The value of the inventory is $" + dvd[i].Calvalue()); totalInStock += dvd[i].getdvdStock(); totalValue += dvd[i].Calvalue(); System.out.println("Total In Stock:" + totalInStock + " Total Value: $" + totalValue); System.out.println("Restock Fee: " + (dvd[i].getdvdStock() * dvd[i].getdvdPrice()) * 0.05);} System.out.println(); } public static void main(String args []) { //Sorting strings String[ ] titles = {"How to Loose a Guy in 10 days", "Coyote Ugly", "Legally Blonde", "Sweet Home Alabama"}; Arrays.sort(titles); //use the built-in sorting routine for (int i = 0; i < 4; i++) System.out.println(titles[ i ]); double ReStockFee = 0.05; new Inventory3a(); } //end method main } class Product { public double dvdItemNumber; public String dvdTitle; public double dvdYear; public double dvdStock; public double dvdPrice; public double totalInStock; public double totalValue; public double ReStockFee; // five-argument constructor Product(double item,String title,double year, double stock, double price ) { dvdItemNumber = item; dvdTitle = title; dvdYear = year; dvdStock = stock; dvdPrice = price; } //end five-argument constructor // set dvd item number public void setdvdItemNumber (double item) { dvdPrice= item; }// end method setdvdItemNumber // return dvd item number public double getdvdItemNumber() { return dvdItemNumber; }// end method getdvdItemNumber // set dvd title public void setdvdTitle (String title) { dvdTitle= title; }// end method setdvdTitle // return dvd title public String getdvdTitle() { return dvdTitle; }// end method getdvdTitle // set dvd year // set dvd stock public void setdvdYear(double year) { dvdYear= year; }// return dvd year public double getdvdYear() { return dvdYear; }// end method getdvdYear // set dvd stock public void setdvdStock(double stock) { dvdStock= stock; } // end method getdvdStock // return dvd stock public double getdvdStock() { return dvdStock; }// end method getdvdStock // set dvd price public void setdvdPrice (double price) { dvdPrice= price; }// end method setdvdPrice // return dvd price public double getdvdPrice() { return dvdPrice; }// end method getdvdPrice // set total in stock public void settotalInStock (double total) { totalInStock= total; }// end method settotalInStock // return total in stock public double gettotalInStock() { return totalInStock; }// end method gettotalInStock // caluclate Inventory public double Calvalue() { return dvdPrice * dvdStock; } //end method value // calculates Total Value public double totalValue(){ return dvdPrice * totalInStock; } // end method value // calculates Re-Stocking Fee public double ReStockingFee(){ return dvdPrice * totalInStock * .05; }// end method value // returns smaller, bigger or equals according to dvdTitle public int compareTo(Object o){ Product other = (Product) o; return dvdTitle.compareTo(other.dvdTitle); } } // end Product Class
| DaniWeb Message | |
| Cancel Changes | |