Untitled
user_3554110889
java
3 years ago
670 B
13
Indexable
public class Activity4_Pine {
public static void main(String[] args) {
int num = 1;
int iteration = 10;
int diff = 5;
String sum = "", prod = "";
int totalsum = 0;
long totalprod = 1;
for (int i = num; i <= iteration * diff; i += diff) {
sum = sum + (sum != "" ? " + " + i : i);
totalsum += i;
prod = prod + (prod != "" ? " * " + i : i);
totalprod *= i;
}
System.out.println("Sum: " + sum + " = " + totalsum);
System.out.println("Product: " + prod + " = " + totalprod);
}
}Editor is loading...