Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / November 2006

Tip: Looking for answers? Try searching our database.

Can I please get some help

Thread view: 
porky008 - 05 Nov 2006 06:22 GMT
Can someone please help me with this? I am not sure on how to finish it
of fix the errors I get. The errors so far are
inventorysupplystock2.java:45: ')' expected     } // end method
setRestockingFee   and
inventorysupplystock2.java:44: illegal start of expression
resstockingFee = (value * 5%)

public class inventorysupplystock2 implements Comparable{
        protected  int count;
        protected  int quantity;
        protected  String productName;
        protected  String productGenre;
        protected  double itemNumber;
        protected  double quantityNumber;
        protected  double unitPrice;
        protected  double unitValue;
        protected  double restockingFee;

       public inventorysupplystock2() {

   }

   public int compareTo(Object o) {
   return productName.compareTo(((inventorysupplystock2)
o).getName());
   }

   public void displayItems(){
       System.out.printf( "%-2s           %-2s          %-2s
%-2s        %.2f        %.2f       %.2f\n",
               itemNumber, productGenre, productName,
               quantityNumber, unitPrice, unitValue, restockingFee);
   }
   // total value per movie
   public void setValue(double value){
       unitValue = value;

   }

   public double getValue(){

         return unitValue;
   }

public void setRestockingFee(double restockingfee)
    {
    resstockingFee = (value * 5%)
    } // end method setRestockingFee

    // return restocking fee
    public double getRestockingFee()
    {
    return restockingFee;
    } // end method getRestockingFee

    // caluculate value + restocking fee
    public double total()
    {
    return restockingFee * Value;
    } // end method total

   public void setCount( int a ){
       count = a;
   }

   // movie name
   public void setName( String name ) {

       productName = name;
   }
   public String getName() {

       return productName;
      }
       // movie genre
   public void setGenre( String genre ) {

       productGenre = genre;
   }
   public String getGenre() {

       return productGenre;
      }

   // item number
   public void setNumber( double number ) {

       itemNumber = number;
   }
   public double getNumber() {

       return itemNumber;
   }
   // quantity of that movie
   public void setquantity( double quantity ) {

       quantityNumber = quantity;
   }
   public double getquantity() {

       return quantityNumber;
   }
   // price for that movie
   public void setPrice( double price ) {

       unitPrice = price;
   }
   public double getPrice(){

       return unitPrice;
   }
}
*********************************************************************
import java.util.Scanner;

public class inventorysupplys2 { // start of class

   public static void main(String[] args) { // start of program

       Scanner input = new Scanner( System.in );
       int c;
       System.out.printf( "\n\nHow many new movies do you want to
enter? ");
       c = input.nextInt();
       input.nextLine();
       inventorysupplystock2[] supply = new inventorysupplystock2[c];

       String name;              // for the name
       String genre;             // this should be the subclass genre
       double number;            // for the item number
       double quantity;          // number of units in stock
       double price;             // price per item
       double value = 0;         // value of that item
       double totalValue = 0;    // value of whole inventory
       double restockingFee = 0; // this should be fo rthe restocking
fee
       int a = 0;
       int b = 0;
       while (a < c){ // start of the loop getting the info for how
ever many you are putting in

           supply[a] = new inventorysupplystock2();
           supply[b] = new inventorysupplystock2();

           System.out.printf( "What is the name of the movie being
entered: ");
           name = input.nextLine();
           supply[a].setName(name);

           // you said i didnt need the extend keywrod
           // so i have a feeling i am way off on this
           System.out.printf( "What is the genre of the movie being
entered: ");
           genre = input.nextLine();
           supply[b].setGenre(genre);

           System.out.printf( "What will be this movie's item number:
");
           number = input.nextDouble();
           input.nextLine();
           supply[a].setNumber(number);

           System.out.printf( "How many are you entering into stock:
");
           quantity = input.nextDouble();
           input.nextLine();
           supply[a].setquantity(quantity);

           System.out.printf( "How much did this movie cost: ");
           price = input.nextDouble();
           input.nextLine();
           supply[a].setPrice(price);

           System.out.printf( "How much is the restocking fee: ");
           fee = input.nextDouble();
           input.nextLine();
           supply[a].setFee(fee);

           value = supply[a].getquantity() * supply[a].getPrice();

           supply[a].setValue(value);

           supply[a].setCount(a);
           // i could not get the restocking fee to work but i do know
its
           // resstockingFee = (value * 5%) i just didnt know how to
do it over a/b

       } // end of loop getting info

       java.util.Arrays.sort(supply); //this sorts the stuff
       System.out.printf( "Item number  Genre   Name   Quantity  Price
Value restockingFee\n");

       a = 0;
       while (a < c){ // total value of inventory
       supply[a].displayItems();

       totalValue += supply[a].getValue();

       a++;
       }

       // total value
       System.out.printf( "The total value of the inventory is: %.2f",
totalValue );
   } // end of program

} // end of class
Tor Iver Wilhelmsen - 05 Nov 2006 08:26 GMT
> inventorysupplystock2.java:45: ')' expected     } // end method
> setRestockingFee   and
> inventorysupplystock2.java:44: illegal start of expression
> resstockingFee = (value * 5%)

These tell you what is missing, and on what line. Why do you think
total strangers are going to be able to help you more than your
compiler already is?

>     resstockingFee = (value * 5%)

You cannot use the percentage sign like that; Java's numbers aren't
aware of percentages. You need to use the number that 5% represents
(0.05).
ge0rge - 05 Nov 2006 17:26 GMT
>>inventorysupplystock2.java:45: ')' expected     } // end method
>>setRestockingFee   and
[quoted text clipped - 4 lines]
> total strangers are going to be able to help you more than your
> compiler already is?

... because total strangers can explain the problem (as you did) in a
language that normal people can understand ;-) I was going to be
facetious and write which part of the compiler message did you not
undertand but on second thought remembered the many blind spots I had
until I became familiar with computer obscurantism.

Signature

Inform all the troops that communications have completely broken down.

Lew - 06 Nov 2006 20:21 GMT
>>     resstockingFee = (value * 5%)

> You cannot use the percentage sign like that; Java's numbers aren't
> aware of percentages. You need to use the number that 5% represents
> (0.05).

>>  public void setRestockingFee(double restockingfee)
>>      {
>>     resstockingFee = (value * 5%)
>>      } // end method setRestockingFee

The method does not use the input parameter.
The target of the assignment has not been defined.

Thinking through error messages may seem tedious, but it is an essential skill
for a developer.  There is no workaround; you must know how to read compiler
errors.

If the compiler indicates "')' expected" at a particular place, take a look at
the place.  What is there instead of a parenthesis?  But there is a
parenthesis, right after the percent sign.  Hmm, must be something about the
percent sign that is messing up the compiler and hiding the parenthesis.
Wait, isn't percent-sign not a part of the Java language?  Drat - ok,
substitute the actual legal Java constant, in this case 0.05.  Cool, it fixed
the error message, but what's this new compiler error about a missing
declaration?  That variable declaration is right up top over here ...., oh,
it's spelled differently.  Fix the spelling - hey, another error gone.

- Lew
Luc The Perverse - 06 Nov 2006 21:34 GMT
>>> resstockingFee = (value * 5%)
>
[quoted text clipped - 24 lines]
> here ...., oh, it's spelled differently.  Fix the spelling - hey, another
> error gone.

Sometimes it is best not to try to interpret what the error message is
telling you, but rather what could possibly be wrong (At least in the case
of mismatched parenthesis, syntax errors and other things which seem to
violate intuition)

You can also comment blocks of code out - and narrow down where your true
syntax error is coming from that way.

--
LTP

:)
porky008 - 07 Nov 2006 05:27 GMT
> >>> resstockingFee = (value * 5%)
> >
[quoted text clipped - 37 lines]
>
> :)

thanks for the help


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.