hi guys, im new here, i have a project that i have to do but cannot complete...

Write a program that prompts the user for a number from 1-9. Then display all of the numbers from 1 to 100 except for any numbers that are evenly divisible by the user’s input or contain the number. For those numbers, print the word “BUZZ. Notice in the example that every number from 30 to 39 would be “BUZZ because they all contain the number 3. For extra credit make any number that is both evenly divisible by the users input and also contains the number print “DOUBLE BUZZ.

Enter a number [1-9]: 3


1 2 DOUBLE BUZZ 4 5 BUZZ 7 8 BUZZ 9 10 11 BUZZ BUZZ 14 BUZZ..

heres what i have so far

import java.util.Scanner;
public class Buzz
{
public static void main(String[] args)
{
int Num;
Scanner scan = new Scanner(System.in);
do
{
System.out.println("Enter a number from 1-9");
Num = scan.nextInt();
}
while(Num < 1 || Num > 9);

for (int count = 1; count != 101; count++)
{
if (count % Num == 0)
{
System.out.println("BUZZ");
}
else if (
else
{
System.out.println(count);
}
}
}
}

so far i can get it to do ne number evenly divisible by the variable, however i do not know how to make it replace a number like 30-39(if 3 is the variable entered)....i tried looking up a way to compare the user input to just 1 character but i couldnt find ne thing relative to my needs....also do not know what to do if its a double buzz situation (both divisible and containing the variable)...id assume that struturally id have to write as

if (divisible or contains variable)
print buzz
else if (divisible and contains)
print double buzz
else
print count

however i just cant for the life of me figure out how to discern if the number contains the variable (if 3 is entered howto make it include 30-39, 73, etc)

well in case ne 1 is wondering i figured out how to fix the program....

i was thinking i had to invoke some method from the math class or something more complicated then what i actually had to do...

since i am only dealing with 2 digit numbers...
say for example i am looking at the number:
35

how do i mathimatically know what the 3 and the 5 seperatly represent
the 3 = 3x10 (remember 10's column and 1's column..etc)
and the 5 = 5x1

so i can seperate the 3 from the 5 using a combination of interger division and modular division

ex: u enter 3 in the program
the program gets to the number 35...both containing and evenly divisible by 3
35 % 3 = 0 then its evenly divisible
35 / 10 = 3 (interger division does not provide remainder) thus forth this number contains a 3
and to check the second digit
35 % 10 = 5....5 is not 3, but if it were this statement would be true


count % Num == 0 (checks even divisibility
count / 10 == Num (checks 10's column to see if it matchs interger entered)
count % 10 == Num (checks 1's column....)

so i got it werking

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.