This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes data-type mismatch Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "data-type mismatch" Watch "data-type mismatch" New topic
Author

data-type mismatch

Mike MacDonald
Greenhorn

Joined: Jan 24, 2005
Posts: 5
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!!!");
}
}





}


Being a newbie at any language is like panhandling. It sucks!!!
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
public Double calculateCost()
probably should be
public double calculateCost()
(small d)
Mike MacDonald
Greenhorn

Joined: Jan 24, 2005
Posts: 5
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

Joined: Jun 09, 2003
Posts: 4632
<identifier> expected
often caused by mis-matched curly braces { and }
leaving the statement outside of a method
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: data-type mismatch
 
Similar Threads
Compilation errors - URGENT!!!
Guidelines for 'extenders' of a class
New to Java - i need help please!
Linked List help
In case you missed it...