Answer to Question #189138 in Visual Basic for Karabo

Question #189138

Code a program to get the number of students and the group size from the user. Calculate and display the number of groups that must be used to divide the students in the given group size. The last group would possibly not be filled. Display also the number of students in the last group.


1
Expert's answer
2021-05-05T02:23:17-0400
Module Module1


    Sub Main()
        'Get the number of students and the group size from the user. 
        Console.Write("Enter the number of students: ")
        Dim numberStudents As Integer = Integer.Parse(Console.ReadLine())
        Console.Write("Enter the group size: ")
        Dim groupSize As Integer = Integer.Parse(Console.ReadLine())
        'Calculate and display the number of groups that must be used to divide the students in the given group size.
        Dim numberStudentsLastGroup As Integer = numberStudents Mod groupSize
        Dim numberGroups As Integer = (numberStudents - numberStudentsLastGroup) / groupSize
        ' The last group would possibly not be filled. Display also the number of students in the last group.
        Console.WriteLine("The number of groups that must be used: {0}", numberGroups)
        Console.WriteLine("The number of students in the last group: {0}", numberStudentsLastGroup)


        Console.ReadLine()
    End Sub


End Module


Output:


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS