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.
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:
Comments
Leave a comment