• Post Reply Bookmark Topic Watch Topic
  • New Topic

data-type mismatch  RSS feed

 
Mike MacDonald
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Let me first say thanks in advance for any help you can provide.

I keep getting this error
/*
incompatible types found : double
required: java.lang.Double
*/

heres my newbie code:

public class Package
{
double weight;
char shippingMethod;
double shippingCost;




public Package(int wgt,char shpMthd)
{
weight=(int)Math.ceil(wgt/16);

shippingMethod=shpMthd;

calculateCost();
}


public Double calculateCost()
{

switch(shippingMethod)
{

case 'A':
if(weight<9)
{
return (double)weight*2.00;break;
}
else if(weight>8 && weight<17)
{
return weight*3.00;break;
}
else
{
return weight*4.50;break;
}


case 'T':
if(weight<9)
{
return weight*1.50;break;
}
else if(weight>8 && weight<17)
{
return weight*2.35;break;
}
else
{
return weight*3.25;break;
}
break;

case 'M':
if(weight<9)
{
return weight*1.50;break;
}
else if(weight>8 && weight<17)
{
return weight*2.35;break;
}
else
{
return weight*3.25;break;
}
break;
default:
System.out.println("No shipping method provided!!!");
}
}





}
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public Double calculateCost()
probably should be
public double calculateCost()
(small d)
 
Mike MacDonald
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
AWESOME it worked!!! OK here is another quickie:

this error:
<identifier> expected
System.out.println("Enter youre the weight of your package. ex.3.1");


this code:

//Weight
System.out.println("Enter youre the weight of your package. ex.3.1");

weight=System.in.read();
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<identifier> expected
often caused by mis-matched curly braces { and }
leaving the statement outside of a method
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!