Problem Statement:
In a forest near Bandipur in INDIA, there are some bamboo trees .The length of each tree get doubled during winter and increases by one unit in summer , write a Java program to calculate the total length of n number of bamboo trees in M number of seasons.The season always starts with winter.
--- Update ---
import java.util.Scanner;
public class Tree {
public static void main(String args[]) {
int length;
int season;
int su, wi;
int sum = 0;
int n = 0;
int TotalLength=0;
System.out.println("enter the number of seasons");
Scanner in = new Scanner(System.in);
season = in.nextInt();
System.out.println("enter the length of tree");
length = in.nextInt();
System.out.println("enter the total number of trees in forest");
n = in.nextInt();
for (int i = 0; i < (season); i++) {
if ((i % 2) == 0) {
length = length * 2;
}
if ((i % 2) != 0) {
length = length + 1;
}
}
TotalLength = length*n;
System.out.println("the total trees lenght is: " + TotalLength);
}
}