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.

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 number or 999 to quit >> PID24584521
Enter last name >> White
Enter balance >> 200
Enter next patient ID number or 999 to quit >> PID98512456
Enter last name >> Pink
Enter balance >> 450
Enter next patient ID number or 999 to quit >> PID21578345
Enter last name >> Brown
Enter balance >> 1000
Enter next patient ID number or 999 to quit >> PID74315491
Enter last name >> Blue
Enter balance >> 650
Enter next patient ID number or 999 to quit >> 999

And the contents of the Patients.txt file:

PID24584521,White,200
PID98512456,Pink,450
PID21578345,Brown,1000
PID74315491,Blue,650
0 0
Add a comment Improve this question Transcribed image text
Answer #1

#source code in python:

class Patient:

id=""

name=""

balance=0

if __name__=="__main__":

p=Patient()

f=open("Patients.txt","a")

while(True):

p.id=input("Enter patient ID number or 999 to quit >>")

if(p.id=="999"):

break

p.name=input("Enter last name >>")

p.balance=int(input("Enter balance >>"))

datalist=[p.id,p.name,str(p.balance)]

f.write(",".join(datalist))

f.write("\n")

f.close()

i 2 3 4 5 6 class Patient: id=. name= balance=0 if 7 8 9 10 11 12 13 14 15 16 17 18 name_ ==_main: p=Patient() f=open (P

#output:

user@user-Latitude - 3490:-/Desktop$ python3.7 1.py Enter patient ID number or 999 to quit >>PID24584521 Enter last name >>Wh

PID24584521, White, 200 PID98512456,Pink,450 PID21578345,Brown, 1000 PID74315491,Blue,650||

#if you have any doubt or more information needed comment below..i will respond as possible as soon...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
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