Chapter 8 Program.
Write a program that allows the user to enter film titles and ratings into the text file. This data should then be read back and displayed.
Film title should hold a maximum of 21 characters and the rating should be held as an integer.
using
System; using System.IO; namespace Films{ class Class1 { static void Main(string[] args) { string filmTitle, filmRating; do { new StreamWriter (File.Open("Films.dat", FileMode.Create, FileAccess.Write, FileShare.ReadWrite)); Console.WriteLine("Enter the title of a film: "); filmTitle = Console.ReadLine(); Console.WriteLine("Enter the rating for the film: "); filmRating = Console.ReadLine(); sw.WriteLine("{0}\t{1}", filmTitle, filmRating); sw.Close(); } while (filmTitle.Length > 22);StreamReader sr = new StreamReader (File.Open("Films.dat", FileMode.Open));
} |