Some help...
-
How would I get a program to show the numbers it adds up? Say the user wants the program to add numbers 1 through 10. How would I get the result to show up as "1+2+3+4+5+6+7+8+9+10=55"? I dont have a problem getting the program to add the numbers or anything. I just need help displaying the result, if it's any help I'll be using a loop. If I havent explained myself well enough let me know. Thanks :)
rawr!
-
How would I get a program to show the numbers it adds up? Say the user wants the program to add numbers 1 through 10. How would I get the result to show up as "1+2+3+4+5+6+7+8+9+10=55"? I dont have a problem getting the program to add the numbers or anything. I just need help displaying the result, if it's any help I'll be using a loop. If I havent explained myself well enough let me know. Thanks :)
rawr!
you want the output to contain two things: a string representing the operands and operations, and the evaluation result. Hence your loop should contain two things: a concatenation adding the latest operator and operand to the symbolic string, and an addition adding the addend to the partial sum. :)
Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles]
Prolific encyclopedia fixture proof-reader browser patron addict?
We all depend on the beast below.
-
How would I get a program to show the numbers it adds up? Say the user wants the program to add numbers 1 through 10. How would I get the result to show up as "1+2+3+4+5+6+7+8+9+10=55"? I dont have a problem getting the program to add the numbers or anything. I just need help displaying the result, if it's any help I'll be using a loop. If I havent explained myself well enough let me know. Thanks :)
rawr!
Module Module1
Sub Main() Dim txt As String = "" Dim arr() As Double = {20, 11, 34, 25, 55, 89} Dim tot As Double = 0 For i As Integer = 0 To 5 If i < 5 Then txt &= arr(i).ToString("0") txt &= "+" tot += arr(i) Else txt &= arr(i) txt &= "=" tot += arr(i) txt &= tot.ToString("0") End If Next Console.WriteLine("Output: {0}", txt) Console.Read() End Sub
End Module
I don't speak Idiot - please talk slowly and clearly 'This space for rent' Driven to the arms of Heineken by the wife