Monday, July 27, 2009

Complicated java programming need help badly?

1. (5)Create a class called Grocery that has three private attributes price (double), quantity(int) and catcode (string).


2. (5)Create a constructor for the abovementioned class that initializes the data members to zero values, and catcode to “N”


3. (30)Create accessor and mutator methods for the class. Make sure that


a. price attribute can not be assigned a negative value. In case of such an error, the default value is 0.00


b. quantity attribute can not be assigned a negative value. In case of such an error, the default value is 0


c. catcode attribute can not be assigned a value other than “N”,”F”,”Z”. In case of such an error, the default value is “N”


4. (5)Create a method called inputprice() that receives no parameters and returns no value. Using JOptionPane class it asks the user to input a price and uses setprice() method to set the value for the data member price.





all i need help with is number 4





import javax.swing.JOptionPane;


public class grocery


{ private....

Complicated java programming need help badly?
public void inputprice()


{


double price;


string input;


input = JOptionPane.showInputDialog("Enter the price:");


price=Double.parseDouble(input);


setprice(price);


}





I think that should be it

survey software

No comments:

Post a Comment