I finally got JCreator to work (@ my previous post).
But now I'm having troble adding to the code for my assignment.
The task at hand is to made fido say "rrrrruff" on the second iteration, but just "ruff" any where else.
here is the original code from my prof.
CODE
class MainApplication {
public static void main(String args[]) {
Dog fido = new Dog();
fido.bark(5);
}
}
// Class Dog
class Dog {
public void bark(int iterations){
int i = 0;
while (i < iterations) {
System.out.println("ruff");
i++;
}
}
}
Here is my attempt; this makes him say "rrrrruff", but it's not on the second line, it's on the fourth. My question is, how do I make him say it on the 2nd only?CODE
class MainApplication {
public static void main(String args[]) {
Dog fido = new Dog();
fido.bark(3);
}
}
// Class Dog
class Dog {
public void bark(int iterations){
int i = 0;
while (i < iterations) {
System.out.println("ruff");
i++;
}
if (i <= 4) {
System.out.println("rrrrruff");
i++;
}
}
}
Thanks!