QUOTE(broli @ Dec 11 2005, 05:12 AM)
I'm stressing out here >_< I'm like so new to vb and console applications. I'm trying to make a calculator in console applications that
can keep adding when i type numbers in until i type '-1' AFter that -1 it would:
give me the total number of entered(+1 each time a number is added),
total scores combined, and
an average of total scores/total numbers entered.
Sad thing is, I'm much better on GUI

I made one in GUI so easily, I guess console is that different.
I can get the average, but the scores and total numbers won't go sometimes.
It's fairly easy - am pasting the working code below. This employes the Console.ReadLine and Console.WriteLine methods to get input and print output respectively. However, ReadLine accepts a string only and I'm using CType to type cast it to an Integer. If you enter an Alphabetic character or a Punctuation mark in the input, this will cause the code to crash. If you want the input checking to be implemented at every step, that can be done too

So let me know..
CODE
Module ConsoleCalc
Sub Main()
'Variables
Dim Num, TotalNums, Sum As Integer
'Print out info and prompt
Console.WriteLine("Enter a series of numbers below, one in each line.")
Console.WriteLine("When you want to end, enter -1")
'Init Vars
TotalNums = 0
Sum = 0
'Loop till -1 is entered
Do
'Accept a number
Num = CType(Console.ReadLine, Integer)
'Check if number is not -1, then add to sum and increment turn
'If you don't introduce this second check, even the -1 will be counted as a number
'is the series and added to it - also the total numbers entered will be wrong
'and throw the average off
If Num <> -1 Then
'Add to sum
Sum += Num
'Increment Turn
TotalNums += 1
End If
Loop While Num <> -1
'Print the results
Console.WriteLine("Total numbers entered: " & TotalNums)
Console.WriteLine("Sum of all numbers: " & Sum)
Console.WriteLine("Average: " & Sum / TotalNums)
End Sub
End Module
I wrote it off in 5 mins and tried it out - fully funtional. If you have any problems running it let me know immediately by return post.
Comment/Reply (w/o sign-up)