Share
Explore BrainMass

Switch Statements

Make this program using switch statements in Visual Basic/C++.

Based the tuition fee of the student to the following:

Year Code Year Name Downpayment
1 Freshmen 10% of tuition fee
2 Sophomore 15% of tuition fee
3 Junior 20% of tuition fee
4 Senior 25% of tuition fee

Course Code Course Name Rate per Unit
A BSCS 205.50
B ENGG. 195.75
C MNGT 180.50
D ARCHI 175.25

Computation: tuition fee= number of units x Rate per unit
balance of tuition fee= tuition fee - downpayment

Enter the year code, course code, number of units and output the year name, course name, tuition fee and the balance tuition fee of the student.

I'm just not sure on putting multiple switch statements.

Solution Preview

I am providing the code in Visual Basic and in C++, but it would be structured identically in other languages just using different syntax. First the input parameters are declared - that's what user would input. Secondly output parameters - that's what user will have as a result. Calculation variables are used for internal calculation. The first switch determines the rate, the second - the downpayment percent. Once you have this data you can compute the tuition fee and the balance.

'Input parameters
Dim inputYearCode As Integer = 1
Dim inputCourceCode As String = "A"
Dim inputUnits As Integer = 20

'Output parameters
Dim outTuitionFee As Double
Dim outBalance As Double
Dim outCourseName As String
Dim outYearName As String

'Calculation ...

Solution Summary

The solution contains program code in Visual Basic and C++ that demonstrates usage of a "switch" statement. Based on year code and course code, the total tution fee is calculated. The switch parameters help us determine the down payment percentage and rate per unit.

$2.19