Article View: aus.computers.java
Article #1191Re: converting integers
From: Java Lover
Date: Wed, 07 Jul 1999 00:00
Date: Wed, 07 Jul 1999 00:00
76 lines
2702 bytes
2702 bytes
Hi I think you have solved your problem now, cya.
Knowledge <don'tsend@email.com.au> wrote in message
news:Kerg3.109$QF3.14392@nsw.nnrp.telstra.net...
> Hi....I am writing this program for my course. I have been mucking around
> with doubles and floats...etc. Though I have tried to set the variables to
> double, I get compile errors. I have changed Integer.parseInt (initString)
> to Double.parseDouble(initString) but this compiles an error and too
mention
> that double A_Invest; also compiles an error.
>
> What I am asking is, Can someone show me how to change the
Integer.parseInt
> (initString) so I can accept decimal input from the command line. Here is
my
> source code:-
>
>
>
>
> import java.io.*;
>
> public class Investment {
>
> public static void main (String[] args)
> throws IOException
> {
>
> BufferedReader stdin = new BufferedReader
> (new InputStreamReader (System.in));
>
>
> String initString;
> int A_Invest;
> int N_Years;
> int Interest_Rate;
> int Value;
> int j;
>
> System.out.print ("Enter the amount to invest: ");
> initString = stdin.readLine();
> A_Invest = Integer.parseInt (initString);
>
> System.out.print (" ");
>
> System.out.print ("Enter the Interest Rate:");
> initString = stdin.readLine();
> Interest_Rate = Integer.parseInt (initString);
>
> System.out.print (" ");
>
> System.out.print ("Enter the number of years: ");
> initString = stdin.readLine();
> N_Years = Integer.parseInt (initString);
>
> System.out.print (" ");
>
> Value = A_Invest * (1 + Interest_Rate) * N_Years;
>
> j = 1;
> for (int i = 0; i < N_Years; i++) {
> System.out.print ("The value of your " + j++);
> System.out.print (" Year return will be: " + Value);
> System.out.println (" ");
> }
> }
> }
>
>
>
>
>
>
>
>
Technical Details
Message-ID:
<Wnwg3.43$SK3.4112@nsw.nnrp.telstra.net>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<Kerg3.109$QF3.14392@nsw.nnrp.telstra.net>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10d6db,712db274a2126081 X-Google-Attributes: gid10d6db,public From: "Java Lover" <javalover@angelfire.com.au> Subject: Re: converting integers Date: 1999/07/07 Message-ID: <Wnwg3.43$SK3.4112@nsw.nnrp.telstra.net> X-Deja-AN: 497939988 References: <Kerg3.109$QF3.14392@nsw.nnrp.telstra.net> X-Priority: 3 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 X-Complaints-To: abuse@telstra.net X-Trace: nsw.nnrp.telstra.net 931304054 203.58.80.244 (Wed, 07 Jul 1999 09:34:14 EST) Organization: Customer of Telstra Big Pond Direct X-MSMail-Priority: Normal NNTP-Posting-Date: Wed, 07 Jul 1999 09:34:14 EST Newsgroups: aus.computers.java