Jump to content

So, for school i have to create a console program that takes in the student's name, input their marks, add the total, average  the class mark. What i can't figure out is how to get a maximum total mark and link it to the student that got it (like: "John got the highest mark of x").

Module Module1    Public studentNames(3) As String    Public testmark1(3) As Integer    Public testmark2(3) As Integer    Public testmark3(3) As Integer    Public total(3) As Integer    Public avg As Integer    Public maxmark As Integer    Dim min, totalmark As Integer    Sub Main()        totalmark = 0        Console.WriteLine("------------------Student Results--------------")        For counter = 0 To 2            studentNames(counter) = InputBox("Candidate Name")            testmark1(counter) = InputBox("Mark")            testmark2(counter) = InputBox("Mark")            testmark3(counter) = InputBox("Mark")            Console.WriteLine("Name:" & studentNames(counter) & " " & "test1: " & testmark1(counter) & " " & "test2: " & testmark2(counter) & " " & "test3: " & testmark3(counter))            #studentNames()            total(counter) = testmark1(counter) + testmark2(counter) + testmark3(counter)            totalmark = totalmark + total(counter)        Next        Console.WriteLine("--------Array Contains-------")        For counter = 0 To 2            # studentNames(total(counter)) = total(counter) + testmark1(counter) + testmark2(counter) + testmark3(counter)            Console.WriteLine("Name: " & studentNames(counter) & " " & "TotalScore " & total(counter))            # Console.ReadLine()        Next        Console.WriteLine("Total Score of Class" & totalmark)        avg = totalmark / 3        Console.WriteLine("Average: " & avg)        Console.ReadLine()        For counter = 0 To 2            If total(counter) > maxmark Then maxmark = total(counter)        Next        Console.WriteLine(studentNames(3) & "got the highest mark of: " & maxmark)        Console.ReadLine()    End SubEnd Module 

Intel i7 4702MQ| Nvidia GTX 850M| Kingston 16GB DDR3 1600Mhz| Acer VA70_HW (mobo)| 1TB WD Blue| MATSHITA DVD-RAM UJ8E0|1600x900 display|Win 8.1

Intel i5 4690K @Stock| Sapphire 390 Nitro| Hyper X Fury 2x4GB| MSI SLI Krait z97| Noctua Nh-U12S | 850 EVO 256GB| 2TB WD Black | CM V 850w| Enthoo Luxe

If you want to tag me or any person with periods do: @[Member='Name]

Link to comment
https://linustechtips.com/topic/301008-need-a-bit-of-help-with-vb-code/
Share on other sites

Link to post
Share on other sites

Sorry for constantly changing the colours.

Intel i7 4702MQ| Nvidia GTX 850M| Kingston 16GB DDR3 1600Mhz| Acer VA70_HW (mobo)| 1TB WD Blue| MATSHITA DVD-RAM UJ8E0|1600x900 display|Win 8.1

Intel i5 4690K @Stock| Sapphire 390 Nitro| Hyper X Fury 2x4GB| MSI SLI Krait z97| Noctua Nh-U12S | 850 EVO 256GB| 2TB WD Black | CM V 850w| Enthoo Luxe

If you want to tag me or any person with periods do: @[Member='Name]

Link to post
Share on other sites

There may be syntax errors because I haven't used VB in 2 years but what you want to do is create 1 mark array and 1 name array. Then something like this:

Dim string currentname;Dim highest = 0;For i = 0 to 2{    if testmark[i] > highest then {  highest = testmark[i];  currentname = studentnames[i]; }}
Link to post
Share on other sites

 

There may be syntax errors because I haven't used VB in 2 years but what you want to do is create 1 mark array and 1 name array. Then something like this:

Dim string currentname;Dim highest = 0;For i = 0 to 2{    if testmark[i] > highest then {  highest = testmark[i];  currentname = studentnames[i]; }}

ah ok, ill try that out once Visual Studio is downloaded.

Intel i7 4702MQ| Nvidia GTX 850M| Kingston 16GB DDR3 1600Mhz| Acer VA70_HW (mobo)| 1TB WD Blue| MATSHITA DVD-RAM UJ8E0|1600x900 display|Win 8.1

Intel i5 4690K @Stock| Sapphire 390 Nitro| Hyper X Fury 2x4GB| MSI SLI Krait z97| Noctua Nh-U12S | 850 EVO 256GB| 2TB WD Black | CM V 850w| Enthoo Luxe

If you want to tag me or any person with periods do: @[Member='Name]

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×