Please Help Compiling Error

Reply

Join Date: Jan 2008
Posts: 3,956
Reputation: VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute 
Solved Threads: 516
Featured Poster
VernonDozier VernonDozier is offline Offline
Senior Poster

Re: Please Help Compiling Error

 
0
  #11
Jul 23rd, 2008
Originally Posted by twgood View Post
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]
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 34
Reputation: twgood is an unknown quantity at this point 
Solved Threads: 0
twgood twgood is offline Offline
Light Poster

Re: Please Help Compiling Error

 
0
  #12
Jul 23rd, 2008
I have changed my code, and it is working but sadly it is not formatting my decimal correctly.
  1. package javaapplication31;
  2.  
  3.  
  4.  
  5. import java.util.Arrays;
  6.  
  7.  
  8.  
  9.  
  10.  
  11. public class Inventory3a{
  12.  
  13.  
  14.  
  15. Inventory3a() { // constructor
  16.  
  17.  
  18.  
  19. Product[] dvd = new Product[4];
  20.  
  21. dvd[0] = new Product(685.0,"How to Loose a Guy in 10 days",2003, 4, 19.99 );
  22. dvd[1] = new Product(565.0,"Coyote Ugly Ugly",2000, 8, 19.98 );
  23. dvd[2] = new Product(785.0,"Legally Blonde",2001, 13, 19.99);
  24. dvd[3] = new Product(578.0,"Sweet Home Alabama",2002, 8,18.56);
  25.  
  26. double totalInStock = 0.0;
  27. double totalValue = 0.0;
  28. double ReStockingFee= 0.0;
  29. for(int i = 0; i < 4; i++)
  30. {
  31.  
  32.  
  33. System.out.println("Item number: " + dvd[i].getdvdItemNumber());
  34. System.out.println("Title: " + dvd[i].getdvdTitle());
  35. System.out.println("Made in: "+ dvd[i].getdvdYear());
  36. System.out.println("In Stock: " + dvd[i].getdvdStock());
  37. System.out.println("The price of each DVD is $" + dvd[i].getdvdPrice());
  38. System.out.println("The value of the inventory is $" + dvd[i].Calvalue());
  39. totalInStock += dvd[i].getdvdStock();
  40. totalValue += dvd[i].Calvalue();
  41. System.out.println("Total In Stock:" + totalInStock +
  42. " Total Value: $" + totalValue);
  43. System.out.println("Restock Fee: " + (dvd[i].getdvdStock() * dvd[i].getdvdPrice()) * 0.05);}
  44. System.out.println();
  45.  
  46. }
  47.  
  48. public static void main(String args []) {
  49.  
  50. //Sorting strings
  51. String[ ] titles = {"How to Loose a Guy in 10 days", "Coyote Ugly", "Legally Blonde", "Sweet Home Alabama"};
  52. Arrays.sort(titles); //use the built-in sorting routine
  53. for (int i = 0; i < 4; i++)
  54. System.out.println(titles[ i ]);
  55.  
  56. double ReStockFee = 0.05;
  57. new Inventory3a();
  58.  
  59. } //end method main
  60.  
  61. }
  62. class Product
  63. {
  64. public double dvdItemNumber;
  65. public String dvdTitle;
  66. public double dvdYear;
  67. public double dvdStock;
  68. public double dvdPrice;
  69. public double totalInStock;
  70. public double totalValue;
  71. public double ReStockFee;
  72.  
  73. // five-argument constructor
  74. Product(double item,String title,double year, double stock, double price )
  75. {
  76. dvdItemNumber = item;
  77. dvdTitle = title;
  78. dvdYear = year;
  79. dvdStock = stock;
  80. dvdPrice = price;
  81.  
  82. } //end five-argument constructor
  83.  
  84. // set dvd item number
  85. public void setdvdItemNumber (double item)
  86. {
  87. dvdPrice= item;
  88. }// end method setdvdItemNumber
  89.  
  90.  
  91. // return dvd item number
  92. public double getdvdItemNumber()
  93. {
  94. return dvdItemNumber;
  95. }// end method getdvdItemNumber
  96.  
  97. // set dvd title
  98. public void setdvdTitle (String title)
  99. {
  100. dvdTitle= title;
  101. }// end method setdvdTitle
  102.  
  103. // return dvd title
  104. public String getdvdTitle()
  105. {
  106. return dvdTitle;
  107. }// end method getdvdTitle
  108.  
  109. // set dvd year
  110. // set dvd stock
  111. public void setdvdYear(double year)
  112. {
  113. dvdYear= year;
  114.  
  115. }// return dvd year
  116. public double getdvdYear()
  117. {
  118. return dvdYear;
  119. }// end method getdvdYear
  120.  
  121. // set dvd stock
  122. public void setdvdStock(double stock)
  123. {
  124. dvdStock= stock;
  125. } // end method getdvdStock
  126.  
  127. // return dvd stock
  128. public double getdvdStock()
  129. {
  130. return dvdStock;
  131. }// end method getdvdStock
  132.  
  133. // set dvd price
  134. public void setdvdPrice (double price)
  135. {
  136. dvdPrice= price;
  137. }// end method setdvdPrice
  138.  
  139.  
  140. // return dvd price
  141. public double getdvdPrice()
  142. {
  143. return dvdPrice;
  144. }// end method getdvdPrice
  145.  
  146. // set total in stock
  147. public void settotalInStock (double total)
  148. {
  149. totalInStock= total;
  150. }// end method settotalInStock
  151.  
  152. // return total in stock
  153. public double gettotalInStock()
  154. {
  155. return totalInStock;
  156. }// end method gettotalInStock
  157.  
  158.  
  159.  
  160. // caluclate Inventory
  161. public double Calvalue() {
  162. return dvdPrice * dvdStock;
  163. } //end method value
  164.  
  165. // calculates Total Value
  166. public double totalValue(){
  167. return dvdPrice * totalInStock;
  168. } // end method value
  169.  
  170. // calculates Re-Stocking Fee
  171. public double ReStockingFee(){
  172. return dvdPrice * totalInStock * .05;
  173. }// end method value
  174.  
  175. // returns smaller, bigger or equals according to dvdTitle
  176. public int compareTo(Object o){
  177. Product other = (Product) o;
  178. return dvdTitle.compareTo(other.dvdTitle);
  179.  
  180. }
  181. } // end Product Class
Last edited by Tekmaven; Jul 24th, 2008 at 2:13 am. Reason: Code tags
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 3,956
Reputation: VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute 
Solved Threads: 516
Featured Poster
VernonDozier VernonDozier is offline Offline
Senior Poster

Re: Please Help Compiling Error

 
0
  #13
Jul 23rd, 2008
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
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 34
Reputation: twgood is an unknown quantity at this point 
Solved Threads: 0
twgood twgood is offline Offline
Light Poster

Re: Please Help Compiling Error

 
0
  #14
Jul 23rd, 2008
  1. package javaapplication31;
  2.  
  3.  
  4.  
  5. import java.util.Arrays;
  6.  
  7.  
  8.  
  9.  
  10.  
  11. public class Inventory3a{
  12.  
  13.  
  14.  
  15. Inventory3a() { // constructor
  16.  
  17.  
  18.  
  19. Product[] dvd = new Product[4];
  20.  
  21. dvd[0] = new Product(685.0,"How to Loose a Guy in 10 days",2003, 4, 19.99 );
  22. dvd[1] = new Product(565.0,"Coyote Ugly Ugly",2000, 8, 19.98 );
  23. dvd[2] = new Product(785.0,"Legally Blonde",2001, 13, 19.99);
  24. dvd[3] = new Product(578.0,"Sweet Home Alabama",2002, 8,18.56);
  25.  
  26. double totalInStock = 0.0;
  27. double totalValue = 0.0;
  28. double ReStockingFee= 0.0;
  29. for(int i = 0; i < 4; i++)
  30. {
  31.  
  32.  
  33. System.out.println("Item number: " + dvd[i].getdvdItemNumber());
  34. System.out.println("Title: " + dvd[i].getdvdTitle());
  35. System.out.println("Made in: "+ dvd[i].getdvdYear());
  36. System.out.println("In Stock: " + dvd[i].getdvdStock());
  37. System.out.println("The price of each DVD is $" + dvd[i].getdvdPrice());
  38. System.out.println("The value of the inventory is $" + dvd[i].Calvalue());
  39. totalInStock += dvd[i].getdvdStock();
  40. totalValue += dvd[i].Calvalue();
  41. System.out.println("Total In Stock:" + totalInStock +
  42. " Total Value: $" + totalValue);
  43. System.out.println("Restock Fee: " + (dvd[i].getdvdStock() * dvd[i].getdvdPrice()) * 0.05);}
  44. System.out.println();
  45.  
  46. }
  47.  
  48. public static void main(String args []) {
  49.  
  50. //Sorting strings
  51. String[ ] titles = {"How to Loose a Guy in 10 days", "Coyote Ugly", "Legally Blonde", "Sweet Home Alabama"};
  52. Arrays.sort(titles); //use the built-in sorting routine
  53. for (int i = 0; i < 4; i++)
  54. System.out.println(titles[ i ]);
  55.  
  56. double ReStockFee = 0.05;
  57. new Inventory3a();
  58.  
  59. } //end method main
  60.  
  61. }
  62. class Product
  63. {
  64. public double dvdItemNumber;
  65. public String dvdTitle;
  66. public double dvdYear;
  67. public double dvdStock;
  68. public double dvdPrice;
  69. public double totalInStock;
  70. public double totalValue;
  71. public double ReStockFee;
  72.  
  73. // five-argument constructor
  74. Product(double item,String title,double year, double stock, double price )
  75. {
  76. dvdItemNumber = item;
  77. dvdTitle = title;
  78. dvdYear = year;
  79. dvdStock = stock;
  80. dvdPrice = price;
  81.  
  82. } //end five-argument constructor
  83.  
  84. // set dvd item number
  85. public void setdvdItemNumber (double item)
  86. {
  87. dvdPrice= item;
  88. }// end method setdvdItemNumber
  89.  
  90.  
  91. // return dvd item number
  92. public double getdvdItemNumber()
  93. {
  94. return dvdItemNumber;
  95. }// end method getdvdItemNumber
  96.  
  97. // set dvd title
  98. public void setdvdTitle (String title)
  99. {
  100. dvdTitle= title;
  101. }// end method setdvdTitle
  102.  
  103. // return dvd title
  104. public String getdvdTitle()
  105. {
  106. return dvdTitle;
  107. }// end method getdvdTitle
  108.  
  109. // set dvd year
  110. // set dvd stock
  111. public void setdvdYear(double year)
  112. {
  113. dvdYear= year;
  114.  
  115. }// return dvd year
  116. public double getdvdYear()
  117. {
  118. return dvdYear;
  119. }// end method getdvdYear
  120.  
  121. // set dvd stock
  122. public void setdvdStock(double stock)
  123. {
  124. dvdStock= stock;
  125. } // end method getdvdStock
  126.  
  127. // return dvd stock
  128. public double getdvdStock()
  129. {
  130. return dvdStock;
  131. }// end method getdvdStock
  132.  
  133. // set dvd price
  134. public void setdvdPrice (double price)
  135. {
  136. dvdPrice= price;
  137. }// end method setdvdPrice
  138.  
  139.  
  140. // return dvd price
  141. public double getdvdPrice()
  142. {
  143. return dvdPrice;
  144. }// end method getdvdPrice
  145.  
  146. // set total in stock
  147. public void settotalInStock (double total)
  148. {
  149. totalInStock= total;
  150. }// end method settotalInStock
  151.  
  152. // return total in stock
  153. public double gettotalInStock()
  154. {
  155. return totalInStock;
  156. }// end method gettotalInStock
  157.  
  158.  
  159.  
  160. // caluclate Inventory
  161. public double Calvalue() {
  162. return dvdPrice * dvdStock;
  163. } //end method value
  164.  
  165. // calculates Total Value
  166. public double totalValue(){
  167. return dvdPrice * totalInStock;
  168. } // end method value
  169.  
  170. // calculates Re-Stocking Fee
  171. public double ReStockingFee(){
  172. return dvdPrice * totalInStock * .05;
  173. }// end method value
  174.  
  175. // returns smaller, bigger or equals according to dvdTitle
  176. public int compareTo(Object o){
  177. Product other = (Product) o;
  178. return dvdTitle.compareTo(other.dvdTitle);
  179.  
  180. }
  181.  
  182. } // end Product Class
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 3,956
Reputation: VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute 
Solved Threads: 516
Featured Poster
VernonDozier VernonDozier is offline Offline
Senior Poster

Re: Please Help Compiling Error

 
0
  #15
Jul 23rd, 2008
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
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 34
Reputation: twgood is an unknown quantity at this point 
Solved Threads: 0
twgood twgood is offline Offline
Light Poster

Re: Please Help Compiling Error

 
0
  #16
Jul 23rd, 2008
I have seen it as return string format but I am not sure what all of the codes mean and which ones i need.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 903 | Replies: 15
Thread Tools Search this Thread



Tag cloud for Java
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2010 DaniWeb® LLC