Results 1 to 3 of 3
  1. #1
    Chicken's Avatar WHY DAVE

    Join Date
    Jul 2012
    Country
    Posts
    174
    Thanked
    36
    Thanks
    45
    Hello is me chicken again guys. Some of you know me from 2016/15-2018, I wanted to ask help to do this assignment as I am not a coder... This is supposed to be in java, thank you, chicken is very grateful.

    Here below:

    Write a void method printPowers which uses a while loop to print the the first three powers of 1 - 5 as shown below.

    1 1 1

    2 4 8

    3 9 27

    4 16 64

    5 25 125

  2. #2
    Bunny's Avatar To bunny or not to be

    Join Date
    Mar 2014
    Country
    Posts
    4,131
    Thanked
    2,469
    Thanks
    918
    heres the code in C#
    Code:
    public void printPowers()
    {
    double i=1.0;
    while (i<6)
    {
    Console.Write(Math.Pow(i, 1.0)+" ");
    Console.Write(Math.Pow(i, 2.0)+" ");
    Console.Write(Math.Pow(i, 3.0));
    Console.WriteLine();
    i++;
    }

  3. #3
    Chicken's Avatar WHY DAVE

    Join Date
    Jul 2012
    Country
    Posts
    174
    Thanked
    36
    Thanks
    45
    Originally Posted by Bunny View Post
    heres the code in C#
    Code:
    public void printPowers()
    {
    double i=1.0;
    while (i<6)
    {
    Console.Write(Math.Pow(i, 1.0)+" ");
    Console.Write(Math.Pow(i, 2.0)+" ");
    Console.Write(Math.Pow(i, 3.0));
    Console.WriteLine();
    i++;
    }
    Thanks bunny. As always you're a great help to me, lov u bro. Keep hustling

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)