Question

Write the program WritePatientRecords that allows a doctor’s staff to enter data about patients and saves...

Write the program WritePatientRecords that allows a doctor’s staff to enter data about patients and saves the data to a file called Patients.txt. The output should be in the following format: p#, PATIENT_NAME, BALANCE. Create a Patient class that contains fields for ID number, name, and current balance owed to the doctor’s office.

using System;
using static System.Console;
using System.IO;
class WritePatientRecords
{
static void Main()
{
// Your code here
}
}

0 0
Add a comment Improve this question Transcribed image text
Answer #1

using System;
using static System.Console;
using System.IO;
class WritePatientRecords
{
static void Main()
{
// Your code here
StreamWriter writer = new StreamWriter("Patients.txt");
char choice;
do
{
Patient p = new Patient();
Console.Write("Enter Patient Id: ");
p.ID = int.Parse(Console.ReadLine());
Console.Write("Enter Patient name: ");
p.Name = Console.ReadLine();
Console.Write("Enter Balance: ");
p.Balance = Double.Parse(Console.ReadLine());
//Write data to file
writer.WriteLine(p);
Console.Write("Enter more data..(y/n): ");
choice = Console.ReadLine().ToLower()[0];
} while (choice == 'y');
writer.Close();
}
}
class Patient
{
private int id;
private string name;
private double balance;
//Constructor
public Patient(int id, string name, double bal)
{
this.id = id;
this.name = name;
this.balance = bal;
}
//Constructor 2
public Patient()
{
id = 0;
name = "";
balance = 0;
}
//Properties
public int ID
{
get
{
return id;
}
set
{
id = value;
}
}
public string Name
{
get
{
return name;
}
set
{
name = value;
}
}
public double Balance
{
get
{
return balance;
}
set
{
balance = value;
}
}
public override string ToString()
{
return "p" + id + ", " + name + ", " + balance;
}
}

//Output

//Patients.txt

//If you need any help regarding this solution ..... please leave a comment.... thanks

Add a comment
Know the answer?
Add Answer to:
Write the program WritePatientRecords that allows a doctor’s staff to enter data about patients and saves...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write the program WritePatientRecords that allows a doctor’s staff to enter data about patients and saves...

    Write the program WritePatientRecords that allows a doctor’s staff to enter data about patients and saves the data to a file called Patients.txt. The output should be in the following format: p#, PATIENT_NAME, BALANCE. Create a Patient class that contains fields for ID number, name, and current balance owed to the doctor’s office. Save the contents of your output file as you will use them in the subsequent labs. An example of the program is shown below: Enter patient ID...

  • Write the program FindPatientRecords that prompts the user for an ID number, reads records from Patients.txt,...

    Write the program FindPatientRecords that prompts the user for an ID number, reads records from Patients.txt, and displays data for the specified record. If the record does not exist, display the following error message: No records found for p# using System; using static System.Console; using System.IO; class FindPatientRecords { static void Main() { // Your code here } }

  • Write the program FindPatientRecords that prompts the user for an ID number, reads records from Patients.txt,...

    Write the program FindPatientRecords that prompts the user for an ID number, reads records from Patients.txt, and displays data for the specified record. If the record does not exist, display the following error message: No records found for p# using System; using static System.Console; using System.IO; class FindPatientRecords { static void Main() { // Your code here } }

  • bject Oriented Programming Home My units BISY2003/1SY2006/ISY211 12 2020 Assessments A4 (Practical 40%) estion 4 yet...

    bject Oriented Programming Home My units BISY2003/1SY2006/ISY211 12 2020 Assessments A4 (Practical 40%) estion 4 yet wered Create a C# application for Library that allows you to enter data for books and saves the data to a file named Books.txt. Create a Book class that contains fields for title, author, number of pages, and price of the book and ToString() method. The fields of records in the file are separated with asterisk (*). Expecting sentinel value for ending the process...

  • Please Help in C#, Let me know if you have any questions. Please make sure the...

    Please Help in C#, Let me know if you have any questions. Please make sure the program passes the checks Checks: Question: My code works, it just this needs to be added there which I don't know what I need to do.    In order to prepend the $ to currency values, the program will need to use the CultureInfo.GetCultureInfo method. In order to do this, include the statement using System.Globalization; at the top of your program and format the output...

  • Create a DataEntryException class whose getMessage() method returns information about invalid integer data. Write a program...

    Create a DataEntryException class whose getMessage() method returns information about invalid integer data. Write a program named GetIDAndAge that continually prompts the user for an ID number and an age until a terminal 0 is entered for both. If the ID and age are both valid, display the message ID and Age OK. Throw a DataEntryException if the ID is not in the range of valid ID numbers (0 through 999), or if the age is not in the range...

  • Write a c# console program called “ArrayOfThings” where you create a class called Staff with private...

    Write a c# console program called “ArrayOfThings” where you create a class called Staff with private fields for StaffID and StaffName. Create Properties that can write data and retrieve data from these private fields. Create a Staff array that can hold up to ten Staff objects. Create ten objects using a for loop that automatically creates a new (empty) Staff object at each iteration of the loop and adds that object into the Staff array. Write data into the first...

  • 7.2 Write a Java program called to create an Excel spreadsheet Create a class called Food...

    7.2 Write a Java program called to create an Excel spreadsheet Create a class called Food to represent a Lunch food item. Fields include name, calories, carbs In a main method (of a different class), ask the user "How many things are you going to eat for lunch?". Loop through each food item and prompt the user to enter the name, calories, and grams of carbs for that food item. Create a Food object with this data, and store each...

  • Suppose there is a hospital with a waiting room filled with several patients. Patients are prioritized...

    Suppose there is a hospital with a waiting room filled with several patients. Patients are prioritized based on how severe their casualities are. For instance, car crash andgun shot patients are priority level 1, so they go straight to the front of the queue. Patients with heavy chest pain or mild heart attacks are priority level 2, and so on. Create a hospital that manages patients in a list. Implement it using the LinkedList API. (You may import ArrayList or...

  • Write a program called EventManager, that allows a user to search for 9-1-1 incidents recorded in Seattle The data is g...

    Write a program called EventManager, that allows a user to search for 9-1-1 incidents recorded in Seattle The data is given to you in file Seattle_911_Incidents.csv which contains 500 records (a subset of the approximately 53,000 911 calls made in Seattle in the years 2015-2017). This dataset is the Police responses to 9-1-1 calls within the city during the 2015-2017 years. You can get the full data set from http://data.seattle.gov. The data consists of 500 rows, where each row is...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT