Results 1 to 5 of 5
- 09-19-2011, 05:15 AM #1
Member
- Join Date
- Sep 2011
- Location
- US
- Posts
- 16
- Rep Power
- 0
how to present thousands, hundreds, tens, and ones ...
Hi guys ..
I am so happy that I found this forum which will help me a lot to improve my java skills.
this is my first question which I tried so many times to fighter out the answer..
tomorrow is the due date for this program so please if you could help me to find an answer for this program ...
I wrote the program .. I guess it's right however I want to know how to present the thousands, hundreds, tens, and ones place value using / and %


this is my program .. Am I doing right ? I attached tow in case ..
please I need a help guys .. I really appreciate your read :)
-
Re: how to present thousands, hundreds, tens, and ones ...
Please post your code as text, not as an image. Place the tag [code] above your code block and [/code] below your code block so it retains its formatting. Also, rather than ask "am I doing right", please tell us what happens when you test it. Are you getting any errors? Is the output as expected?
- 09-19-2011, 06:02 AM #3
Member
- Join Date
- Sep 2011
- Location
- US
- Posts
- 16
- Rep Power
- 0
Re: how to present thousands, hundreds, tens, and ones ...
I am sorry this is it
my program which has many problemsJava Code://Problem Analysis //Input:Four digit Number //Process:1) Check input for appropriate length (size) – if too small or too large give a message and exit //2) Find the thousands, hundreds, tens, and ones place value. Calculate the sum and product of the four digits. //3) Determine appropriate message for product //Output:Initial integer with sum and product of digits in a suitable format //Hint: Use the % operator to extract digits, and use the / operator to remove the extracted digits. //For instance 932 % 10 = 2 and 932 / 10 = 93.
Java Code:public class Program2 { public static void main(String[] args) { String userInput = JOptionPane .showInputDialog("Enter a positive four digit number between 1000 and 9999: "); int fourDigitNumber = Integer.parseInt(userInput); if ( fourDigitNumber <= 999 ) if ( fourDigitNumber > 9999) { JOptionPane.showMessageDialog(null, "Number is not a positive four digit number between 1000 and 9999 inclusive.", "Sami's Program", JOptionPane.ERROR_MESSAGE); } else { JOptionPane.showMessageDialog(null, "The original number is:" + String + "The sum of the four digits is:" + sum + "The product of the four digits is:" + product , "me", JOptionPane.PLAIN_MESSAGE); } int inputString = (userInput); int sum = int product = System.exit(0); } }
-
Re: how to present thousands, hundreds, tens, and ones ...
- 09-19-2011, 06:15 AM #5
Member
- Join Date
- Sep 2011
- Location
- US
- Posts
- 16
- Rep Power
- 0
Re: how to present thousands, hundreds, tens, and ones ...
Yes you are right. I am sorry maybe because of my english a little weak. I wrote this program as the instruction said
my biggest problem is number 2 .. Find the thousands, hundreds, tens, and ones place value. Calculate the sum and product of the four digits. ??//Problem Analysis
//Input:Four digit Number
//Process:1) Check input for appropriate length (size) – if too small or too large give a message and exit
//2) Find the thousands, hundreds, tens, and ones place value. Calculate the sum and product of the four digits.
//3) Determine appropriate message for product
//Output:Initial integer with sum and product of digits in a suitable format
//Hint: Use the % operator to extract digits, and use the / operator to remove the extracted digits.
//For instance 932 % 10 = 2 and 932 / 10 = 93.
Also how can I present the ( origin, sum and product ) ?
Similar Threads
-
What is the most efficient data structure for storing possibly upto thousands of ...
By oontvoo in forum Advanced JavaReplies: 4Last Post: 08-05-2011, 04:10 PM -
how to access a file in the present folder.
By AnanthNag.Kundanala in forum New To JavaReplies: 2Last Post: 01-11-2011, 03:40 PM -
longest word present in a string
By somnath6088 in forum New To JavaReplies: 4Last Post: 11-09-2010, 05:43 PM -
How to read a .EML file present on Remote Desktop?
By anil@prokarma in forum New To JavaReplies: 0Last Post: 06-12-2008, 02:05 PM -
To send email of page present Web from a Jsp
By Marcus in forum JavaServer Pages (JSP) and JSTLReplies: 1Last Post: 06-09-2007, 04:08 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks