Miss Strawberry
11-11-2006, 01:24 AM
Can we convert Double to INteger??
Integer_value=Integer.parseInt(Double_value);
Or we cant?
Integer_value=Integer.parseInt(Double_value);
Or we cant?
|
Click to See Complete Forum and Search --> : can we convert Double to integer? Miss Strawberry 11-11-2006, 01:24 AM Can we convert Double to INteger?? Integer_value=Integer.parseInt(Double_value); Or we cant? Miss Strawberry 11-11-2006, 03:16 AM here is my program,, import javax.swing.JOptionPane; public class PartA { public static void main(String[] args) { String money_s, money_double; double money_d, dirham_f; int money_int,money, tens, fives, ones, fifty_fils, twentyFive_fils, ten_fils, five_fils, one_fils; String Message=""; money_s=JOptionPane.showInputDialog("Enter an amount of money: "); money_d=Double.parseDouble(money_s); dirham_f = money_d * 100; String money_double = (new Double(dirham_f).toString(); money=Integer.parseInt(money_double); when I want to convert it to string it wont work:( String money_double = (new Double(dirham_f).toString(); money=Integer.parseInt(money_double); I need help with it please yitzle 11-12-2006, 01:32 AM Not sure if this is the error, but you have an unmatched bracket: String money_double = (new Double(dirham_f).toString(); String money_double = new Double(dirham_f).toString(); chazzy 11-12-2006, 09:29 PM You can always take the easy way out... Double dirham_f; int p = (int)dirham_f; agent_x91 11-13-2006, 03:41 AM I agree with chazzy, you could simply get an int that way. If it is absolutely necessary you could also construct an Integer from that int as well. webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved. |