# Thread: Help with printing intigers divisible by 10?

1. Member
Join Date
Oct 2013
Posts
1
Rep Power
0

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

2. ## 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. Senior Member
Join Date
Jan 2013
Location
Northern Virginia, United States
Posts
5,749
Rep Power
10

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

Regards,
Jim

4. Member
Join Date
Nov 2012
Location
Johannesburg, South Africa
Posts
92
Rep Power
0

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