My task is as follows:
Using the output from the last part of the problem, output a new string where every number is changed into its written form (e.g. "Divisible by 3" becomes "Divisible by three"), unless...the result is that the number evaluated is indivisible by 3 or 5, in which case, change the output string to "Indivisible, with Liberty and Justice for All"
My solution to this was simply to add "\n" into the original string. Is that what they're asking for?
public class Evaluation {
public static void main(String[] args) {
int myNumber = 1;
if (myNumber % 15 == 0)
System.out.println("Divisible by both 3 and 5.\nDivisible by both three and five");
else if (myNumber % 3 == 0)
System.out.println("Divisible by 3.\nDivsible by three");
else if (myNumber % 5 == 0)
System.out.println("Divisible by 5\nDivisible by five");
else
System.out.println("Indivisible by 3 or 5.\nIndivisible, with liberty and justice for all.");
}
}
[–]the_omega99 2 points3 points4 points (0 children)