*******task2******
package com.model.test;
import java.util.Scanner;
/**
* task2
*
*/
public class NewTest {
public static void main(String[] args) {
System.out.println("please enter the number of rows:");
@SuppressWarnings("resource")
Scanner scan = new Scanner(System.in);
int number = scan.nextInt();
if(number < 0){
System.out.println("Error,number of rows must be positive");
}else if(number % 2 == 0){
System.out.println("Error,number of rows must be odd");
}else{
for(int i=1;i<=(number+1)/2;i++){
StringBuilder sb = new StringBuilder();
for(int count=0;count<i;count++){
sb.append("+");
}
if(i > 1){
for(int total=0;total<i-1;total++){
sb.append("+");
}
}
String str = sb.toString();
System.out.println(str);
}
for(int k=(number+1)/2-1;k>=1;k--){
StringBuilder bu = new StringBuilder();
for(int count=0;count<k;count++){
bu.append("+");
}
if(k > 1){
for(int total=0;total<k-1;total++){
bu.append("+");
}
}
String str = bu.toString();
System.out.println(str);
}
}
}
}
*******task3******
package com.model.test;
import java.util.Scanner;
/**
* task3
*
*/
public class MyTest {
public static void main(String[] args) {
System.out.println("Enter the starting number of organisms (2 or more):");
Scanner sc = new Scanner(System.in);
int start = sc.nextInt();
if(start < 2){
System.out.println("Error,starting number must be at least 2.Please re-enter:");
}else{
System.out.println("Enter the daily population increase rate as a percentage(eg. 3.5):");
Scanner scan = new Scanner(System.in);
float rate = scan.nextFloat();
if(rate < 0){
System.out.println("Error,increase rate must be positive.Please re-enter:");
}else{
System.out.println("Enter the number of days the organisms will be left to multiply:");
Scanner sca = new Scanner(System.in);
int days = sca.nextInt();
if(days < 0){
System.out.println("The number of days must be positive.Please re-enter:");
}else{
for(int i=1;i<=days;i++){
int total = (int)((100 + rate) * start)/100;
System.out.println("Population after day" + i + ":" + total);
start = total;
}
}
}
}
}
}