VISUAL STUDIO
(NO JAVA CODING)
Create a C# Console Application project to compute the tuition
fee a student should pay.
In this part of the assignment, you are required to create a C#
Console Application project.
Project name should be A2<FirstName><LastName>P1. For
example a student with first name John and Last name Smith would
name the project A2JohnSmithP1.
Step 1: Ask if a student is a Canadian Citizen or an International
Student. Also ask for their age. You must use an If-Else-Elseif
statement to get full marks.
Logic:
If the student's age is 18 or below, they must pay $300 + 13%
HST
If the student is aged 19 to 49, they must pay $500 + 13%
HST
If the student is aged 50 or above, they must pay $400 + 13%
HST
If the student is an international student, they must pay an
extra $100 before tax is applied.
Step 2: Ask for the month the student registered. You must use a
switch statement to get full marks.
Logic:
If they registered in any of the Fall months (Sept., Oct., Nov.,
or Dec.), add $250 + 13% HST
If they registered in any of the Winter months (Jan., Feb., Mar.
or Apr.), add $220 + 13% HST
If they registered in any of the Summer months (May, Jun., Jul.
or Aug.), add $150 + 13% HST
Calculate the total tuition a student owes by adding up the value
obtained in Step 1 and Step 2.
Show the total tuition fee on the C# Console application. The
display will look something contain:
The Student's age (as entered)
International Student (or not) (as entered)
Registration Semester (as entered)
Base Tuition (as calculated by the application)
International Student fee (if applicable, as calculated by the
application)
Registration Fee for semester (as calculated by the
application)
HST (as calculated by the application)
Final Total (as calculated by the application)
Create a new C# console application with the name A2<FirstName><LastName>P1as said above, I used A2JohnSmithP1.
Add the below code in Program.cs
Program:
using System;
namespace A2JohnSmithP1
{
class Program
{
static void Main(string[] args)
{
string citizen;
bool isCanadian;
int age;
double total = 0.0, baseTuitionFee = 0.0, internationalFee = 0.0,
HST = 0.0, registrationFee = 0.0;
//prompt and read if Student is Canadian Citizen
Console.Write("\nAre you a Canadian Citizen(y/n)? ");
citizen = Console.ReadLine();
//if y is entered set isCanadian to true
if (citizen.ToLower() == "y")
{
isCanadian = true;
}
else
{
//else set isCanadian to false
isCanadian = false;
}
//prompt and read the age
Console.Write("\nEnter your age: ");
age = Convert.ToInt32(Console.ReadLine()); ;
//if age is less than or equal to 18
if (age <= 18)
{
//set base fee
baseTuitionFee = 300;
//calculate HST
HST = HST + ((baseTuitionFee * 13) / 100);
}
//if age is greater than or equal to 19 and less then or equal to
49
else if(age>=19 && age<=49)
{
//set base fee
baseTuitionFee = 500;
//calculate HST
HST = HST + ((baseTuitionFee * 13) / 100);
}
//if age is greater than or equal to 50
else if (age >=50)
{
//set base fee
baseTuitionFee = 400;
//calculate HST
HST = HST + ((baseTuitionFee * 13) / 100);
}
//if student is international student set intenationfee
if (isCanadian == false)
internationalFee = 100;
//prompt and read the month, assuming that student entered full
month name
String month;
Console.Write("\nEnter the month the student registered: ");
month=Console.ReadLine();
//run a switch case using month
switch (month.ToLower())
{
//if month is Sept., Oct., Nov., or Dec.
case "september":
case "october":
case "november":
case "december":
//set registration fee
registrationFee = 250;
//calculate HST
HST = HST + ((registrationFee * 13) / 100);
break;
//if month is Jan., Feb., Mar. or Apr.
case "january":
case "february":
case "march":
case "april":
//set registration fee
registrationFee = 220;
//calculate HST
HST = HST + ((registrationFee * 13) / 100);
break;
//if month is May, Jun., Jul. or Aug.
case "may":
case "june":
case "july":
case "august":
//set registration fee
registrationFee = 150;
//calculate HST
HST = HST + ((registrationFee * 13) / 100);
break;
default:
//if invalid month is entered show error msg and exit the
program
Console.WriteLine("\nYou entered an invalid month.. the application
is terminated.");
break;
}
//calculate total fee
total = baseTuitionFee + registrationFee + HST +
internationalFee;
if (registrationFee != 0)
{
//print the fee details
Console.Write("\nThe Student's age: " + age);
if(isCanadian)
Console.Write("\nInternation Student: NO" );
else
Console.Write("\nInternation Student: YES");
Console.Write("\nRegistration Semester: "+month);
Console.Write("\nBase Tuition:
$"+baseTuitionFee.ToString("0.00"));
Console.Write("\nInternation Student fee: $" +
internationalFee.ToString("0.00"));
Console.Write("\nRegistration Fee for Semester: $" +
registrationFee.ToString("0.00"));
Console.Write("\nHST: $" + HST.ToString("0.00"));
Console.Write("\nFinal Total: $" + total.ToString("0.00"));
}
Console.ReadKey();
}
}
}
Output:
Get Answers For Free
Most questions answered within 1 hours.