Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: season tree

  1. #1
    Junior Member
    Join Date
    Feb 2014
    Thanked 0 Times in 0 Posts

    Default season tree

    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);


  2. #2
    Join Date
    Feb 2014
    My Mood
    Thanked 7 Times in 7 Posts

    Default Re: season tree

    So what is your question??

Similar Threads

  1. Binary Tree ( Family Tree)
    By tommyacton in forum Algorithms & Recursion
    Replies: 0
    Last Post: March 23rd, 2013, 10:40 PM
  2. Binary Search Tree inorder tree traversal
    By Maukkv in forum What's Wrong With My Code?
    Replies: 17
    Last Post: January 26th, 2013, 05:28 PM
  3. Data Structures(Binary Search Tree to AVL Tree)ASAP
    By jfAdik in forum Algorithms & Recursion
    Replies: 2
    Last Post: April 5th, 2010, 03:58 AM