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.
A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
Win a copy of
Arduino in Action
this week in the
General Computing
forum!
A special promo:
Enter your blog post or vote on a blogger to be featured in an upcoming Journal
JavaRanch
»
Java Forums
»
Java
»
Beginning Java
Author
data-type mismatch
Mike MacDonald
Greenhorn
Joined: Jan 24, 2005
Posts: 5
posted
Apr 14, 2005 19:28:00
0
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
posted
Apr 14, 2005 19:36:00
0
public Double calculateCost()
probably should be
public double calculateCost()
(small d)
Mike MacDonald
Greenhorn
Joined: Jan 24, 2005
Posts: 5
posted
Apr 14, 2005 19:41:00
0
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
posted
Apr 14, 2005 20:03:00
0
<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...
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter