In: Computer Science
Sum the odd integers between 1 and 99 using a for structure. Assume the integer variables sum and count have been declared.
Calculate the value of 2.5 raised to the power of 3 using pow method.
Print the integers from 1 to 20 using a while loop and the counter variable x. Assume that the variable x has been declared but not initialized. Print only five integers per line.[ Hint: Use calculation x % 5. When the value of this is 0, print a newline character; otherwise, print a tab character. Assume this is an application- use the System.out.println() method to output the newline character and use the System.out.print( ‘\t’ ) method to output the tab character.]
Repeat Exercise 2 c) using for structure.
public class Calculation
{
    public static void main(String[] args)
    {
        int sum=0,i;
        for(i=3;i<99;i=i+2)
        {
            sum=sum+i;
        }
        System.out.println("Sum of odd integers between 1 to 99 is "+sum);
    }
}

----------------------------------------------------------------------------------------------------------------------------------------------------
public class Calculation
{
    public static void main(String[] args)
    {
       float base= (float) 2.5;
        double result;
        int exponent=3;
       result=Math.pow(base,exponent);
        System.out.println(result);
    }
}

----------------------------------------------------------------------------------------------------------------------------------
public class Calculation
{
    public static void main(String[] args)
    {
        int x=1;
       while(x<=20)
       {
           System.out.print(x);
           if(x%5==0)
           {
               System.out.println();
           }
           else
           {
               System.out.print('\t');
           }
           x++;
       }
    }
}

----------------------------------------------------------------------------------------------------------
public class Calculation
{
    public static void main(String[] args)
    {
        for(int x=1;x<=20;x++)
       {
           System.out.print(x);
           if(x%5==0)
           {
               System.out.println();
           }
           else
           {
               System.out.print('\t');
           }
       }
    }
}

***********************************************************************************************************************************