| | |
Please Help Compiling Error
![]() |
•
•
Join Date: Jan 2008
Posts: 3,956
Reputation:
Solved Threads: 516
•
•
•
•
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.
Post your updated code with Java-style code tags, which will add line numbers, then refer to the specific line number you are referring to. I don't know what line you are speaking about and I don't know if you have changed your code. For certain, you need to change or delete the line of code referred to earlier in this thread.
[code=JAVA]
// paste code here. Line #'s are added.
[/code]
•
•
Join Date: May 2008
Posts: 34
Reputation:
Solved Threads: 0
I have changed my code, and it is working but sadly it is not formatting my decimal correctly.
JAVA Syntax (Toggle Plain Text)
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
Last edited by Tekmaven; Jul 24th, 2008 at 2:13 am. Reason: Code tags
•
•
Join Date: Jan 2008
Posts: 3,956
Reputation:
Solved Threads: 516
Close. You got the end tag wrong. It's
[code=JAVA]
// paste code
[/code]
not
[code=JAVA]
// paste code
[/code=JAVA]
The beginning code tag was correct. Hit the "Preview" button first. That gives you a chance to see your post and edit it before publishing it. You'll see right away on the preview whether the code tags are correct, and you can see the line number to refer us to. Here's a link for DecimalFormat, which could come in handy.
http://java.sun.com/j2se/1.4.2/docs/...malFormat.html
[code=JAVA]
// paste code
[/code]
not
[code=JAVA]
// paste code
[/code=JAVA]
The beginning code tag was correct. Hit the "Preview" button first. That gives you a chance to see your post and edit it before publishing it. You'll see right away on the preview whether the code tags are correct, and you can see the line number to refer us to. Here's a link for DecimalFormat, which could come in handy.
http://java.sun.com/j2se/1.4.2/docs/...malFormat.html
•
•
Join Date: May 2008
Posts: 34
Reputation:
Solved Threads: 0
JAVA Syntax (Toggle Plain Text)
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
•
•
Join Date: Jan 2008
Posts: 3,956
Reputation:
Solved Threads: 516
What's the question? It ran, but You haven't implemented the DecimalFormat that I linked. Here's a good example of it from Daniweb.
http://www.daniweb.com/forums/thread20141.html
http://www.daniweb.com/forums/thread20141.html
![]() |
Similar Threads
- Another "cannot find symbol" compiling error (Java)
- compiling error, tried debugging but no luck (C)
- compiling error - help (C++)
- error 88:'(' expected when trying to display an array any help (Pascal and Delphi)
- compiling error wtf!?!? (C)
- Please help me out, need help (C)
Other Threads in the Java Forum
- Previous Thread: help please
- Next Thread: java.lang.NoClassDefFoundError: ???
Views: 903 | Replies: 15
| Thread Tools | Search this Thread |
Tag cloud for Java
add android applet arguments array arraylist arrays binary bluetooth c++ chat class classes client code compiler component convert converter coordinates data database db design detection eclipse error event exception file forloop fractal givemetehcodez graphics gridlayout gui helpwithhomework homeworkassignment html ide image images inheritance input integer j2me java jframe jmf jni jpanel key lazy linked linked-list list loop main method methods mobile netbeans newbie node number object objects oracle os parameter pattern phone pixel printing problem program programming read remote remove return robot scanner server set size sms sort sql string swing system test text text-file thread transfer tree user web






