Results 1 to 5 of 5
- 10-30-2012, 12:36 AM #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, 02:20 AM #2
Re: Have too many decimals in my basic program! Please help!
Forum Rules
http://www.java-forums.org/forum-gui...w-members.html
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
dbIf you're forever cleaning cobwebs, it's time to get rid of the spiders.
- 10-30-2012, 05: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 05:29 AM.
- 10-30-2012, 07:35 AM #4
- 10-30-2012, 10:36 AM #5
Moderator
- Join Date
- Apr 2009
- Posts
- 13,541
- Rep Power
- 27
Similar Threads
-
Payroll program will not print decimals... could someone help?
By xgodx415 in forum New To JavaReplies: 2Last Post: 08-01-2011, 12:19 AM -
Assistance with Basic authentication program
By Fargo94 in forum New To JavaReplies: 4Last Post: 05-17-2011, 10:22 AM -
3 basic program
By jasskulainen in forum New To JavaReplies: 3Last Post: 09-27-2009, 02: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, 02:58 PM -
Basic Program Please Help!!
By VinceGuad in forum New To JavaReplies: 3Last Post: 02-01-2008, 04:35 PM
Bookmarks