Hey guys,
I've constructed this program and I have this error that I don't understand.
What I'm trying to do is have a user type in a positive number and then it counts up to that number. If the number is divisible by 3 or by 5, it prints Beep instead. If the number is divisble by 3 and 5 it prints Beep Beep instead.
Here is my program so far:
//BeepBeep.java
//
import java.util.Scanner;
public class BeepBeep
{
// prompts for and reads in positive integer limit
//
// prints out each number from 1 up to limit unless
// the number is divisible by 3 or divisble by 5.
// for numbers divisble by 3 and only or by 5, it prints Beep
// instead of the number, for numbers divisble by 3 and by 5
// it prints Beep-Beep instead of the number.
public static void main(String[] args)
{
Scanner Scan = new Scanner (System.in);
int number;
System.out.println("What positive integer should we count up to?");
number = Scan.nextInt();
System.out.println("BeepBeep to"+number+":");
int count = 0;
while ( count < number)
{
if ( number / 3 || 5)
{
System.out.println("Beep");
}
else if ( number / 3 && 5)
{
System.out.println("Beep-Beep");
}
}
count ++;
}
}
Errors when compiled:
BeepBeep.java:30: operator || cannot be applied to int,int
if ( number / 3 || 5)
^
BeepBeep.java:34: operator && cannot be applied to int,int
else if ( number / 3 && 5)
^
2 errors
----jGRASP wedge: exit code for process is 1.
----jGRASP: operation complete.
Thanks in advance!
Wootens