# Help with printing intigers divisible by 10?

• 10-02-2013, 08:08 AM
robkule424
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(System.in);
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;
lowest++;

System.out.println(lowest);

}

}

If someone can help me out with this one that would be great. An explanation would be great as well. Thank you.
• 10-02-2013, 08:18 AM
Junky
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.
• 10-02-2013, 04:39 PM
jim829
Re: Help with printing intigers divisible by 10?
Well, I did notice this.
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.

Regards,
Jim
• 10-02-2013, 05:19 PM
Kagiso
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