alaios
04-24-2004, 08:26 AM
Plz have a look in this small program and the error that compiler returns
/*
* book.java
*
* Created on 09 April 2004, 01:07
*/
package Package;
/**
*
* @author alaios1
*/
public class book {
String title;
String code;
String last;
String isbn;
Integer quantity;
Float price;
/** Creates a new instance of book */
public book(String mytitle,String mycode,String mylast) {
title=mytitle;mycode=code;mylast=last;
}
public book(String mytitle,String mycode,String mylast,String myisbn,Integer myquantity,Float myprice) {
title=mytitle;code=mycode;last=mylast;isbn=myisbn;quantity=myquantity;price=myprice;
}
public void setTitle(String mytitle) {title=mytitle;}
public void setCode(String mycode) {code=mycode;}
public void setLast(String mylast) {last=mylast;}
public void setIsbn(String myisbn) {isbn=myisbn;}
public void setQuantity(Integer myquantity) {quantity=myquantity;}
public void setPrice(Float myprice) {price=myprice;}
public String getTitle(){return title;}
public String getCode(){return code;}
public String getLast(){return last;}
public String getIsbn(){return isbn;}
public Integer getQuantity(){return quantity;}
public Float getPrice(){return price;}
public Float getValue(Integer discount){return (float)(discount*price);} //Find out what to return here
public void showBook (){} //How i must show the book?
}
/*---Compiler Erros --- */
public Float getValue(Integer discount){return (float)(discount*price);} //Find out what to return here
^
Package/book.java [40:1] incompatible types
found : float
required: java.lang.Float
public Float getValue(Integer discount){return (float)(discount*price);} //Find out what to return here
^
2 errors
Errors compiling book.
As you can see i cannot conver to float.... Why ..? What i must do?
/*
* book.java
*
* Created on 09 April 2004, 01:07
*/
package Package;
/**
*
* @author alaios1
*/
public class book {
String title;
String code;
String last;
String isbn;
Integer quantity;
Float price;
/** Creates a new instance of book */
public book(String mytitle,String mycode,String mylast) {
title=mytitle;mycode=code;mylast=last;
}
public book(String mytitle,String mycode,String mylast,String myisbn,Integer myquantity,Float myprice) {
title=mytitle;code=mycode;last=mylast;isbn=myisbn;quantity=myquantity;price=myprice;
}
public void setTitle(String mytitle) {title=mytitle;}
public void setCode(String mycode) {code=mycode;}
public void setLast(String mylast) {last=mylast;}
public void setIsbn(String myisbn) {isbn=myisbn;}
public void setQuantity(Integer myquantity) {quantity=myquantity;}
public void setPrice(Float myprice) {price=myprice;}
public String getTitle(){return title;}
public String getCode(){return code;}
public String getLast(){return last;}
public String getIsbn(){return isbn;}
public Integer getQuantity(){return quantity;}
public Float getPrice(){return price;}
public Float getValue(Integer discount){return (float)(discount*price);} //Find out what to return here
public void showBook (){} //How i must show the book?
}
/*---Compiler Erros --- */
public Float getValue(Integer discount){return (float)(discount*price);} //Find out what to return here
^
Package/book.java [40:1] incompatible types
found : float
required: java.lang.Float
public Float getValue(Integer discount){return (float)(discount*price);} //Find out what to return here
^
2 errors
Errors compiling book.
As you can see i cannot conver to float.... Why ..? What i must do?