Thursday, June 19, 2008

import java.text.*;
import java.util.*;

public class Robot
{
private String robotName;
private double priceEach;
private int numSold;

// Empty constructor
public Robot()
{
}

//Full constructor- numSold should be set to zero!!
public Robot(String r- double p)
{
robotName = r;
priceEach = p;
double numSold = 0;
}

public int getNumSold() {
return numSold;
}

public void setNumSold(int numSold) {
this.numSold = numSold;
}

public double getPriceEach() {
return priceEach;
}

public void setPriceEach(double priceEach) {
this.priceEach = priceEach;
}

public String getRobotName() {
return robotName;
}

public void setRobotName(String robotName) {
this.robotName = robotName;
}

// totalValue() method
public double totalValue(){
double amount;
amount = numSold * priceEach;
return amount;
}
// updateSales() method- The numSold variable should return nothing!!
//Parameter is the number of addition of that type sold. Add this to the
//number to the numbSold instance variable and return nothing!
public int updateSales(int update){
int sales;
sales = update + numSold;
}

// The toString method is always required
public String toString(){
return (robotName +" has sold "+ numSold + " items costing " + money.format(priceEach) + "each for a total of "+ money.format(amount));
}
}
It says the following:

java.lang.NoSuchMethodError: main
Exception in thread "main"

I get the problem at the bottom of the program:

public int updateSales(int update){
int sales;
sales = update + numSold;
}

// The toString method is always required
public String toString(){
return (robotName +" has sold "+ numSold + " items costing " + money.format(priceEach) + "each for a total of "+ money.format(amount));
}
}

Apart from sun.forum what are the other best websites that could provide technical help for java related questions and problems. sometimes even if i have googled enough i could not solve certain error that i am facing and when i post it i have to wait too long sometimes. Please suggest me any other good websites- forums or even live chat that could provide java help.
Please help me.
Thanks a lot for your answer mike but i need pages that are free of charge service.

Hi
I have an avery that is six by 4 on the outside and 3 by six in the inside.i have zebras and canarys and i was thinking of getting java finchs and budgies-can i get some info on this

// My mind has gone blank and some parts are incomplete. The directions
//are in the comments!
// write a full constructor
public Harvest (String c- int p- double pr)
{
crop= c;
pounds= p;
priceEach= pr;
}
// write a toString method
public String toString()
return ( )

// write a method named cost. It takes no parameters and returns a double
// It is used to calculate the total value of the crop
public double cost()
{
return ("The total value of the crop is " + c);
}

// write a method named storageFee. It takes no parameters and returns a double
// charge them three cents a pound if they store over 10-000 pounds
// otherwise charge them five cents a pound.
public double storageFee()
{
double newFee = c * .03;
return newFee;
}
//write a method named netCost that takes two parameters ( the gross value and the
// storage fee). It returns a double which is the net value of the crop (subtract out what the storage fee was)
**I have to create this program- that is why I am still missing some info. I need to create more content and answer the comments in order for it to compile.
Thanks snew- but it will not let me compile it. It is giving me an error at the following:


// write a toString method
{
return ("Crop: " + crop + " Pounds: " + pounds + " Price: " + priceEach);
}

I am trying to read from a database- but I am getting a error message saying
RESULT SET IS CLOSED

String sqlQuery = "SELECT " +
"* FROM Customers " +
"WHERE Name like + %" + namemem + "% ";

ResultSet rsJob = stmt.executeQuery(sqlQuery);
while
(rs.next())
{
String output =
rsJob.getString(1) + "-"
+rsJob.getString(2) + "-"
+rsJob.getString(3) + "-"
+rsJob.getString(4) + "/n";

JOptionPane.showMessageDialog(null- output);

Does anyone know what that means?
I have a method called : getDBReady();
this initiates the stmt - connection command.

Anythoughts?

if (value == MAX)
if (value < sum)
System.out.println ("value == MAX and < sum.");
else
System.out.printlin ("value is not equal to MAX.");
Thank you very much!!

No comments: