Results 1 to 5 of 5
- 10-29-2012, 11:36 PM #1
Member
- Join Date
- Oct 2012
- Posts
- 1
- Rep Power
- 0
Have too many decimals in my basic program! Please help!
I'm real new at this. I'm looking for an output that shows a number like this $500.00 instead of $500.00000001. Here's what I have so far-
import java.text.*;
import java.util.Scanner;
public class Commission{
public static void main (String[] args){
Scanner kb = new Scanner(System.in);
double a = 1.1, b, c;
DecimalFormat formattedDollars= new DecimalFormat("$#,##0.00");
System.out.println("What is your fixed salary?");
b = kb.nextDouble();
c = b * a;
System.out.println("Your fixed salary is $" + b +" ");
System.out.println("With the current commission being 10% of total sales," +
"your total annual compensation is $" + c);
}
}
- 10-30-2012, 01:20 AM #2
Re: Have too many decimals in my basic program! Please help!
Forum Rules
Guide For New Members
BB Code List - Java Programming Forum
Code Conventions for the Java Programming Language: Contents
Cross posted after getting and apparently ignoring tons of good advice
Why so many decimal points in my basic code? - Page 3
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 10-30-2012, 04:02 AM #3
Member
- Join Date
- Oct 2012
- Posts
- 13
- Rep Power
- 0
Re: Have too many decimals in my basic program! Please help!
Try this...
Java Code:import java.text.*; float thePrice=10.00f; System.out.println("The price is " + NumberFormat.getCurrencyInstance().format(thePrice));Last edited by DrummondAW; 10-30-2012 at 04:29 AM.
- 10-30-2012, 06:35 AM #4
- 10-30-2012, 09:36 AM #5
Moderator
- Join Date
- Apr 2009
- Posts
- 10,459
- Rep Power
- 16
Similar Threads
-
Payroll program will not print decimals... could someone help?
By xgodx415 in forum New To JavaReplies: 2Last Post: 07-31-2011, 11:19 PM -
Assistance with Basic authentication program
By Fargo94 in forum New To JavaReplies: 4Last Post: 05-17-2011, 09:22 AM -
3 basic program
By jasskulainen in forum New To JavaReplies: 3Last Post: 09-27-2009, 01:39 PM -
Java Program To Convert A Number In To Words With Decimals
By javanewbie in forum New To JavaReplies: 1Last Post: 07-02-2008, 01:58 PM -
Basic Program Please Help!!
By VinceGuad in forum New To JavaReplies: 3Last Post: 02-01-2008, 03:35 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks