I have to do a program onj Visual Basic Express 2005 with these following instructions:
Write a function square() that will take an integer and return its square, and a function cube() that will take an integer and return its cube. Use your square() and cube() functions to write the functions quartic() and quintic() that return the fourth and fifth power of an integer respectively. Use your functions to write a program that prints a table of powers of integers from 1 to 25. The output of your program should look like this:
INTEGER:
1
2
3 etc.
SQUARE:
1
4
9 etc.
CUBE:
1
8
27 etc
QUARTIC:
1
16
81 etc
QUINTIC:
1
32
243 etc
Do not use any Math. functions - multiplication only.
I need help to do this i dont really get what it is asking hope someone can help me. Thanks.
Comments
Here is some help I'm willing to offer you:
[italic]Write a function square() that will take an integer and return its square, and a function cube() that will take an integer and return its cube. Use your square() and cube() functions to write the functions quartic() and quintic() that return the fourth and fifth power of an integer respectively. Use your functions to write a program that prints a table of powers of integers from 1 to 25. The output of your program should look like this:[/italic]
[code]
Write 4 functions:
Square(Integer) As Integer
Cube(Integer) As Integer
Quartic(Integer) As Integer
Quintic(Integer) As Integer
Write a program that:
Loops from 1 to 25 and evaluates the LoopCounter being sent to those functions
*Since the output should be a list of Squares, then a list of Cubes, Etc,
*you should run 4 loops that do the output of each function from
*1 to 25
[/code]
[code]
'Example of a function that returns an integer sent to it * 2.
Public Function TimesTwo(ByVal X as Integer) as Integer
Return X*2
End Function
'Example of using this function in a Loop on a Button Click
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Debug.WriteLine("Times Two!") 'display in the output window of the IDE
Dim i As Integer = 0
For i = 1 to 25
'You could assign it to a new variable
'Dim Answer as Integer = TimesTwo(i)
'Debug.WriteLine(Answer)
'But why write two lines, when we can write 1?
Debug.WriteLine(TimesTwo(i))
Next i
End Sub
[/code]
Good luck,
Sean Campbell - Firesickle.com