4947 until your se3sion times out! Enrollment: Add Classes My Grades CS121-resou
ID: 3581488 • Letter: 4
Question
4947 until your se3sion times out! Enrollment: Add Classes My Grades CS121-resources sample-final pct Welcome, abdullah Blackboard 3. (20 points) Write code that prints multiples of 3 from 100 down to 1 but only if the multiple are odd. However if the multiple of 3 is also a multple of 11, then instead of the number print "Yay!" (Note: There are no command line arguments and there should be no user input in this method. The output is on one line as shown below.) Yay! 93 87 81 75 69 63 57 51 45 39 Yay! 27 21 15 9 3 public class Test public static void main (String[] args) ccp 259 boise state Google SearchExplanation / Answer
class Test{
public static void main(String args[]){
for(int i=100;i>0;i--){
// number divisible by 3 and multiple is odd
if((i%3 ==0) && ((i/3)%2==1)){
// if multiple of 11
if(i%11==0){
System.out.print("Yay! ");
}
else
System.out.print(i+" ");
}
}
System.out.println();
String[] mySlangs = new String[10];
for(int i=0;i<mySlangs.length;i++){
System.out.println(mySlangs[i]);
}
}
}
/* sample output
Yay! 93 87 81 75 69 63 57 51 45 39 Yay! 27 21 15 9 3
null
null
null
null
null
null
null
null
null
null
*/
public interface ChangeListener{
public void stateChanged(ChangeEvent e);
}
class MyListener implements ChangeListener{
public void stateChanged(ChangeEvent e){
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.