🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: aus.computers.java
Article #1183

How to input Decimal figures in a input line

#1183
From: mrbafner
Date: Sat, 03 Jul 1999 00:00
71 lines
2843 bytes
Hi,

How can you input numbers in decimal form, here is the program I am working
on, but I cannot input decimal number (example 4.50). If this is possible I
would really appreciate the response, thanks.

===========================================================


import java.io.*;
 public class PayPacket {

   final static double Tax_Rate           = 0.3;    // tax rate percentage

   public static void main (String[] args)
       throws IOException
   {
     System.out.println ("SALES TAX CALCULATOR");    // create a text input
stream


     BufferedReader stdin   =   new BufferedReader
        (new InputStreamReader (System.in));

// this  allow people to input something, then the computer can work of
these figures

     String initString;
     double HourlyRate;          // stores user input
     double NoOfHours;          // stores user input
     double GrossPay; // stores salary before tax tax
     double tax;                 // stores payable tax
     double NetPay;                 // stores pay after tax


     System.out.print ("Enter the Hourly Rate: " + "\n");
     initString      =   stdin.readLine();
     HourlyRate   =   Integer.parseInt (initString);    // calculate payable
tax

     System.out.print ("Number of Hours Worked: \n");
     initString      =   stdin.readLine();
     NoOfHours   =   Integer.parseInt (initString);



GrossPay = HourlyRate * NoOfHours ;

     if (GrossPay >0 )
     {
       tax =  GrossPay * Tax_Rate ;
     }

     else
     {
       tax = 0;
     }    // calculate NetPay

     NetPay = GrossPay - tax;     // Output NetPay

     System.out.println();
     System.out.println("Hourly Rate               : " + HourlyRate );
     System.out.println("Hours Worked               : " + NoOfHours );
     System.out.println("Gross Pay               : " + GrossPay );
     System.out.println("Total Tax (" + Tax_Rate + " %): " + tax );
     System.out.println("--------------------------------");
     System.out.println("Net Pay           : " + NetPay );
   }
 }

=================================================================
Technical Details
Message-ID: <iP8f3.257$ZS2.16444@nsw.nnrp.telstra.net>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10d6db,e8b377bae8907342,start
X-Google-Attributes: gid10d6db,public
From: "mrbafner" <mrbafner@ozlinx.com.au>
Subject: How to input Decimal figures in a input line
Date: 1999/07/03
Message-ID: <iP8f3.257$ZS2.16444@nsw.nnrp.telstra.net>
X-Deja-AN: 496537012
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 930945358 203.58.80.244 (Sat, 03 Jul 1999 05:55:58 EST)
Organization: Customer of Telstra Big Pond Direct
X-MSMail-Priority: Normal
NNTP-Posting-Date: Sat, 03 Jul 1999 05:55:58 EST
Newsgroups: aus.computers.java