0% found this document useful (0 votes)
35 views2 pages

Computer Science Structure Chart Program

The document describes a Visual Basic program that tracks sales data for multiple salespeople. It initializes variables, inputs sales amounts for each salesperson, calculates totals for individual salespeople using either IF statements or a CASE statement, calculates a grand total and overall average, and outputs the results. Key data structures include arrays to store the running totals for each salesperson and variables to track the overall totals and averages.

Uploaded by

dabr
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views2 pages

Computer Science Structure Chart Program

The document describes a Visual Basic program that tracks sales data for multiple salespeople. It initializes variables, inputs sales amounts for each salesperson, calculates totals for individual salespeople using either IF statements or a CASE statement, calculates a grand total and overall average, and outputs the results. Key data structures include arrays to store the running totals for each salesperson and variables to track the overall totals and averages.

Uploaded by

dabr
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Module Program

Dim SalesPersonID, salescounter As Integer


Dim SalesAmt, GrandTotalSales, OverallAvgSales As Double
Dim SalesPersonTotal(3) As Double
Dim caseorif As Integer

Sub Main()
Call Initialise()
Do
Call Inputdata()
Call Processdata()
Loop Until SalesPersonID = -1
Call GrandTotal()
Call Overallaverage()
Call Outputdata()
Console.ReadKey()
End Sub
Sub Initialise()
For I = 1 To 3
SalesPersonTotal(I) = 0
Next
GrandTotalSales = 0
salescounter = 0
End Sub
Sub Processdata()
Console.WriteLine("Choose to use CASE or IF selecion. Enter 1 to use CASE, 2 to use
IF")
caseorif = Console.ReadLine

If caseorif = 2 Then
Call CASEtotalling()
ElseIf caseorif = 1 Then
Call IFtotalling()
End If

salescounter += 1
End Sub
Sub Inputdata()
Do
Console.WriteLine(“Enter Salesperson’s ID: 1, 2 or 3. Enter -1 to exit”)
SalesPersonID = Console.ReadLine
Loop Until SalesPersonID = 1 Or SalesPersonID = 2 Or SalesPersonID = 3 Or
SalesPersonID = -1
If SalesPersonID <> -1 Then
Console.WriteLine(“Enter sales amount”)
SalesAmt = Console.ReadLine
End If
End Sub
Sub IFtotalling()
If SalesPersonID = 1 Then
SalesPersonTotal(1) += SalesAmt
ElseIf SalesPersonID = 2 Then
SalesPersonTotal(2) += SalesAmt
ElseIf SalesPersonID = 3 Then
SalesPersonTotal(3) += SalesAmt
ElseIf SalesPersonID = -1 Then
Else
Console.WriteLine("Error: plz enter 1,2 or 3")
End If
End Sub
Sub CASEtotalling()
Select Case SalesPersonID
Case 1
SalesPersonTotal(1) += SalesAmt
Case 2
SalesPersonTotal(2) += SalesAmt
Case 3
SalesPersonTotal(3) += SalesAmt
Case -1
Case Else
Console.WriteLine("Error: plz enter 1,2 or 3")
End Select
End Sub
Sub GrandTotal()
For z = 1 To 3
GrandTotalSales += SalesPersonTotal(z)
Next
End Sub
Sub Overallaverage()
salescounter -= 1
OverallAvgSales = GrandTotalSales / salescounter
End Sub
Sub Outputdata()
Console.WriteLine("Average of all sales: " & OverallAvgSales)
Console.WriteLine("Total overall sales: " & GrandTotalSales)
For x = 1 To 3
Console.WriteLine("Total for sales person " & x & ": " & SalesPersonTotal(x))
Next
End Sub
End Module

You might also like