Answered step by step
Verified Expert Solution
Question
1 Approved Answer
import java.util.Scanner; public class Lab09 { public static void main ( String[] args ) { int num; Scanner in = new Scanner(System. in ); System.
import java.util.Scanner; public class Lab09{ public static void main(String[] args) { int num; Scanner in = new Scanner(System.in); System.out.print(" Enter a number : "); num = in.nextInt(); for(int i = 1;i <= num;i++){ if(i % 2 != 0) System.out.print(2*i+" "); else System.out.print(-(2*i-1)+" "); } System.out.println(); } static boolean isEven(int num) { if (num % 2 == 0) { return true; } else { return false; } } }
add a method and call it multiple3or7(num) that gets an int number and returns true if the number is a multiple of 3 or 7.
Then, use that method inside your loop to count how many numbers are a multiple of 3 or 7. Match the formatting below.
>run Lab09 Enter a number: 10 2 -3 6 -7 10 -11 14 -15 18 -19 10: 6 multiple of 3 or 7
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started