Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

use NESTED IF..ELSE to solve this problem: There are 7 people. Write a program t

ID: 646018 • Letter: U

Question

use NESTED IF..ELSE to solve this problem:

There are 7 people. Write a program to ask the user to enter the yearly income of each person. As the user enters an income, count the number of people who belong to each of the following groups

1)Those who made less than or equal to30000

2) Those who made above 30000 and less than or equal to 50000

3) Those who made above 50000 and less than or equal to 75000

4) Those who made above 75000

Also, display the total(Combined) earning made by all people.

Just basic only. No c+ or SQL

Explanation / Answer

Module VBModule

    Sub Main()
        Dim p1, p2, p3, p4, p5, p6, p7, total as Decimal
        Dim c1, c2, c3, c4 as Integer
        c1 = 0
        c2 = 0
        c3 = 0
        c4 = 0
        Dim grade as Char
        Console.Write("Income for Person1: ")
        p1 = Convert.toDecimal(Console.ReadLine())
        Console.Write("Income for Person2: ")
        p2 = Convert.toDecimal(Console.ReadLine())
        Console.Write("Income for Person3: ")
        p3 = Convert.toDecimal(Console.ReadLine())
        Console.Write("Income for Person4: ")
        p4 = Convert.toDecimal(Console.ReadLine())
        Console.Write("Income for Person5: ")
        p5 = Convert.toDecimal(Console.ReadLine())
        Console.Write("Income for Person6: ")
        p6 = Convert.toDecimal(Console.ReadLine())
        Console.Write("Income for Person7: ")
        p7 = Convert.toDecimal(Console.ReadLine())
        If p1 <= 30000 Then
            c1 += 1
        ElseIf p1 <= 50000 Then
            c2 += 1
        ElseIf p1 <= 75000 Then
            c3 += 1
        ElseIf p1 > 75000 Then
            c4 += 1
        End If
        If p2 <= 30000 Then
            c1 += 1
        ElseIf p2 <= 50000 Then
            c2 += 1
        ElseIf p2 <= 75000 Then
            c3 += 1
        ElseIf p2 > 75000 Then
            c4 += 1
        End If
        If p3 <= 30000 Then
            c1 += 1
        ElseIf p3 <= 50000 Then
            c2 += 1
        ElseIf p3 <= 75000 Then
            c3 += 1
        ElseIf p3 > 75000 Then
            c4 += 1
        End If
        If p4 <= 30000 Then
            c1 += 1
        ElseIf p4 <= 50000 Then
            c2 += 1
        ElseIf p4 <= 75000 Then
            c3 += 1
        ElseIf p4 > 75000 Then
            c4 += 1
        End If
        If p5 <= 30000 Then
            c1 += 1
        ElseIf p5 <= 50000 Then
            c2 += 1
        ElseIf p5 <= 75000 Then
            c3 += 1
        ElseIf p5 > 75000 Then
            c4 += 1
        End If
        If p6 <= 30000 Then
            c1 += 1
        ElseIf p6 <= 50000 Then
            c2 += 1
        ElseIf p6 <= 75000 Then
            c3 += 1
        ElseIf p6 > 75000 Then
            c4 += 1
        End If
        If p7 <= 30000 Then
            c1 += 1
        ElseIf p7 <= 50000 Then
            c2 += 1
        ElseIf p7 <= 75000 Then
            c3 += 1
        ElseIf p7 > 75000 Then
            c4 += 1
        End If
        total = p1 + p2 + p3 + p4 + p5 + p6 + p7
        Console.WriteLine(Convert.toString(c1) + " persons made less than or equal to 30000")
        Console.WriteLine(Convert.toString(c2) + " persons made above 30000 and less than or equal to 50000")
        Console.WriteLine(Convert.toString(c3) + " persons made above 50000 and less than or equal to 75000")
        Console.WriteLine(Convert.toString(c4) + " persons made above 75000")
        Console.WriteLine("total earning made by all people is " + Convert.toString(total))
    End Sub

End Module