In: Computer Science
Patient.cs :
//namespace
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//application namespace
namespace ConsoleApp_Patient
{
class Patient //C# class
{
//private fields for patientid, lastname,firstname, age, and
email.
private int patientid;
private string lastname;
private string firstname;
private int age;
private string email;
//public data items for each of these private fields with get
and
//set methods
public int PatientID //Public field for patientid
{
get { return patientid; }
set
{
patientid = value;//set patinetid
}
}
public string LastName //Public field for lastname
{
get { return lastname; }
set
{
lastname = value.ToUpper();//set lastname in upper case
}
}
public string FirstName //Public field for firstname
{
get { return firstname; }
set
{
firstname = value;//set firstname
}
}
public int Age //Public field for age
{
get { return age; }
set
{
age = value;//set age
}
}
public string Email //Public field for email
{
get { return email; }
set
{
email = value;//set email
}
}
}
}
-------------------------------- WRITE IN C# ----------------
Modify the patient class with two overloaded methods to display a bill for astandard visit based on age. In the first method do not use any parameters to pass in data. If the patient is over 65, then a standard visit is $75. If the patient is under 65, then the standard doctors office visit is $125. Build a second method where you pass in a discount rate. If the patient is over 65, then apply the discount rate to a standard rate of $125. Create a main method that calls both of these methods and displays the results
//namespace
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//application namespace
namespace ConsoleApp_Patient
{
class Patient //C# class
{
//private fields for
patientid, lastname,firstname, age, and email.
private int
patientid;
private string
lastname;
private string
firstname;
private int age;
private string
email;
//public data items for
each of these private fields with get and
//set methods
public int PatientID
//Public field for patientid
{
get { return patientid; }
set
{
patientid = value;//set patinetid
}
}
public string LastName
//Public field for lastname
{
get { return lastname; }
set
{
lastname = value.ToUpper();//set lastname in upper case
}
}
public string FirstName
//Public field for firstname
{
get { return firstname; }
set
{
firstname = value;//set firstname
}
}
public int Age //Public
field for age
{
get { return age; }
set
{
age = value;//set age
}
}
public string Email
//Public field for email
{
get { return email; }
set
{
email = value;//set email
}
}
// overloaded methods
// takes no
argument
public void
DisplayBill() {
if(Age >=65 ) {
Console.WriteLine(" Bill Amount for a standard visit is 75$
");
}
else {
Console.WriteLine(" Bill Amount for a standard visit is 125$
");
}
}
// takes discount as an
argument
public void
DisplayBill(float discount ) {
if(Age >=65 ) {
float bill = 75 - (discount/100)*75;
Console.WriteLine(" Bill Amount for a standard visit is:
"+bill);
}
else {
float bill = 125 - (discount/100)*125;
Console.WriteLine(" Bill Amount for a standard visit is: "+
bill);
}
}
}
}
THANK YOU!! If you have any doubt, please ask in comment section, I will answer ASAP. If you like my effort please UPVOTE.