C Sharp Program:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace Library
{
//Book Class
class Book
{
private String title;
private String author;
private int numPages;
private double price;
//Constructor
public Book(String t, String a, int np, double p)
{
title = t;
author = a;
numPages = np;
price = p;
}
//ToString method
public String ToString()
{
return title + "*" + author + "*" + numPages + "*" + price;
}
}
class Program
{
//Main method
static void Main(string[] args)
{
String tTitle, tAuthor;
int tNumPages;
double tPrice;
int cnt = 1;
//Opening file for writing
using (StreamWriter writer = new StreamWriter("Books.txt"))
{
while (true)
{
Console.Write("\nEnter title of the book(000 to end): ");
tTitle = Console.ReadLine();
//Checking title
if (tTitle.Equals("000") == true)
{
break;
}
Console.Write("Enter author of the book: ");
tAuthor = Console.ReadLine();
Console.Write("Enter number of pages in the book: ");
tNumPages = Convert.ToInt32(Console.ReadLine());
Console.Write("Enter price of the book: ");
tPrice = Convert.ToDouble(Console.ReadLine());
//Creating Book object
Book b = new Book(tTitle, tAuthor, tNumPages, tPrice);
//Writing to file
writer.WriteLine(cnt.ToString()+"*"+b.ToString());
cnt++;
}
}
Console.ReadLine();
}
}
}
____________________________________________________________________________________________
Sample Run:

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