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)