Results 1 to 5 of 5
  1. #1
    smasm is offline Member
    Join Date
    Sep 2011
    Location
    US
    Posts
    16
    Rep Power
    0

    Default 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 %

    how to present thousands, hundreds, tens, and ones ...-progr2.jpg



    this is my program .. Am I doing right ? I attached tow in case ..

    please I need a help guys .. I really appreciate your read :)

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default 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. #3
    smasm is offline Member
    Join Date
    Sep 2011
    Location
    US
    Posts
    16
    Rep Power
    0

    Default 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. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

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

    Quote Originally Posted by smasm View Post
    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. #5
    smasm is offline Member
    Join Date
    Sep 2011
    Location
    US
    Posts
    16
    Rep Power
    0

    Default 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 ) ?

Similar Threads

  1. Replies: 4
    Last Post: 08-05-2011, 05:10 PM
  2. how to access a file in the present folder.
    By AnanthNag.Kundanala in forum New To Java
    Replies: 2
    Last Post: 01-11-2011, 04:40 PM
  3. longest word present in a string
    By somnath6088 in forum New To Java
    Replies: 4
    Last Post: 11-09-2010, 06:43 PM
  4. How to read a .EML file present on Remote Desktop?
    By anil@prokarma in forum New To Java
    Replies: 0
    Last Post: 06-12-2008, 03:05 PM
  5. To send email of page present Web from a Jsp
    By Marcus in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 06-09-2007, 05:08 AM

Posting Permissions

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