Uploaded by Pinky Pie

Loop WS 1 (Part B) - 2021

advertisement
AP Computer Science - Loop WS 1 – 2021 (Part B)
Complete the following methods
Name_______________________
1. Use a for loop to count the number of multiples of 7 between int a and int b
(inclusive)
public static int countMult7(int a, int b)
{
}
2. Use a while loop to find the sum of all the multiples of 12 less than 100
public static int multTwelves()
{
}
3. Use a nested for loop to print the 5 times table (1 x 1 up to 5 x 5 in a grid)
public static int timesTable ()
{
}
4. Determine whether n is prime.
public static int isPrime(int n)
{
}
Return true/false
Download