Demo entry 6360367

Pre-Release

   

Submitted by anonymous on May 01, 2017 at 13:06
Language: VB.net. Code size: 2.8 kB.

Dim finalbalance As Decimal
        Dim studentspaid As Integer
        Dim totalpayment As Integer
        Dim discount As Integer
        Dim numberofstudents As Integer
        Dim costperstudent As Decimal
        Dim totalcost As Decimal
        Dim studentnames(45) As String
        Dim paidornot(45) As Boolean
        Const maxnumber = 45
        Const coachcost = 550
        Const entryticket = 30
        studentspaid = 0
        Do
            Console.WriteLine("Enter the number of students:")
            numberofstudents = Console.ReadLine
            If numberofstudents > maxnumber Then
                Console.WriteLine("Please enter a valid number!")
            End If
        Loop Until numberofstudents <= maxnumber And numberofstudents > 0
        discount = (numberofstudents \ 10) * entryticket
        costperstudent = entryticket + coachcost / numberofstudents
        totalcost = coachcost + (entryticket * numberofstudents) - discount
        Console.WriteLine("The total cost is:" & totalcost)
        Console.WriteLine("The cost per student is:" & costperstudent)
        For counter = 1 To numberofstudents
            Console.WriteLine("Enter the name of the student:")
            studentnames(counter) = Console.ReadLine
            Console.WriteLine(" Has the student paid or not { True or Fasle }")
            paidornot(counter) = Console.ReadLine
            Do Until paidornot(counter) = "True" Or paidornot(counter) = "False"
                Console.WriteLine(" Has the student paid or not { True or Fasle }")
                paidornot(counter) = Console.ReadLine
            Loop
        Next counter
        Console.WriteLine("The names of the students who have paid are:")
        For counter = 1 To numberofstudents
            If paidornot(counter) = True Then
                studentspaid = studentspaid + 1
                Console.WriteLine(studentnames(counter))
            End If
        Next
        Console.WriteLine("The names of the students who haven't paid are:")
        For counter = 1 To numberofstudents
            If paidornot(counter) = False Then
                Console.WriteLine(studentnames(counter))
            End If
        Next
        totalpayment = studentspaid * costperstudent
        finalbalance = totalcost - totalpayment
        Console.WriteLine(" The school's final balance is " & finalbalance)
        If totalpayment > totalcost Then
            Console.WriteLine(" You have made a profit of $" & finalbalance)
        ElseIf totalpayment = totalcost Then
            Console.WriteLine(" You have broken even")
        Else
            Console.WriteLine(" Your have made a loss of $" & finalbalance)
        End If

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).