Results 1 to 4 of 4
  1. #1
    robkule424 is offline Member
    Join Date
    Oct 2013
    Rep Power

    Default Help with printing intigers divisible by 10?

    Been working on this one for a couple hours, can't seem to figure it out.

    My assignment is to prompt the user to enter a range of numbers, then print those numbers that are divisible by 10. Also print an * next to those that are also divisible by 30 as well.

    Here's what I have so far:

    import java.util.Scanner;

    public class DivBy10and30
    public static void main(String[] args)
    System.out.println("This program will print numbers divisible by 10 ");
    System.out.println("between the lowest and highest values you specify.");
    System.out.println("It also places an * next to those divisible by 30.");

    Scanner scan = new Scanner(;
    int lowest;
    int highest;
    System.out.print("Please enter the lowest value : ");
    lowest = scan.nextInt();
    System.out.print(" Please enter the highest value : ");
    highest = scan.nextInt();

    lowest = (lowest%=10 && lowest);
    lowest = lowest + 10;




    If someone can help me out with this one that would be great. An explanation would be great as well. Thank you.

  2. #2
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Rep Power

    Default Re: Help with printing intigers divisible by 10?

    Work what out? You need to be more specific about what your problem is. Are you getting errors? Then post the exact error messages. If there is some part of the code that is not working as expected then explain what is happening and what should be happening.

  3. #3
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Northern Virginia, United States
    Rep Power

    Default Re: Help with printing intigers divisible by 10?

    Well, I did notice this.
    Java Code:
    lowest = (lowest%=10 && lowest);

    I am not even certain what you are doing here but his won't work (it won't even compile).
    Only boolean values or relational statements can be used like this.

    This is Java, not Perl.

    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  4. #4
    Kagiso is offline Member
    Join Date
    Nov 2012
    Johannesburg, South Africa
    Rep Power

    Default Re: Help with printing intigers divisible by 10?

    if(aNumber % 10 == 0)

    You'll have to learn how to use a modulous operator(%) and you'll have to learn about using if-Statements

    if(condition) // condition has to be a boolean variable or boolean expression or simply a boolean literal(true/false)
    you can't put ant int as a condition
    if(intValue) won't work

Similar Threads

  1. Printing
    By asai in forum AWT / Swing
    Replies: 1
    Last Post: 12-17-2012, 05:59 PM
  2. Replies: 0
    Last Post: 12-26-2011, 03:52 PM
  3. Replies: 9
    Last Post: 08-19-2011, 12:59 AM
  4. printing string backwards and printing every other
    By droidus in forum New To Java
    Replies: 22
    Last Post: 03-10-2011, 09:17 AM
  5. Printing Help...
    By chiragkini in forum AWT / Swing
    Replies: 1
    Last Post: 02-17-2009, 06:07 AM

Tags for this Thread

Posting Permissions

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