# Thread: how to present thousands, hundreds, tens, and ones ...

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 ..

2. ## 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?

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

Java 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.```
my program which has many problems

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);
}
}```

4. ## Re: how to present thousands, hundreds, tens, and ones ...

Originally Posted by smasm
I am sorry this is it

Java 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.```
my program which has many problems

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);
}
}```
OK, what problems does it have? The more details you tell us, the better we can help you. OTOH, the more you hide from us, the less we know and understand about your problem, the less we can help. Makes sense, right?

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

//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.
my biggest problem is number 2 .. Find the thousands, hundreds, tens, and ones place value. Calculate the sum and product of the four digits. ??

Also how can I present the ( origin, sum and product ) ?

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•