public string Title { get; set; }
public string Author { get; set; }
public int DatePublished { get; set; }
public double Price { get; set; }
public Book(string title, string author, int datePublished, double price)
DatePublished = datePublished;
public Book(string title, string author, int datePublished)
DatePublished = datePublished;
static bool checkout = true;
Console.WriteLine("Welcome to the bookstore!");
Console.WriteLine("Select an item to buy: \n [1] Books ($5-$15) \n [2] Pencils ($1) \n [3] View Books \n [4] Bookmarks ($2) \n [5] Checkout");
choice = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Invalid choice");
} while (checkout == true);
Book[] books = new Book[5];
books[0] = new Book("The Great Gatsby", "F. Scott Fitzgerald", 1925, 5.00);
books[1] = new Book("The Hunger Games, Catching Fire", "Suzan Collins", 2009, 6.00);
books[2] = new Book("Fifty Shades Of Grey", "E.L James", 2011, 10.00);
books[3] = new Book("1984", "George Orwell", 1949, 12.00);
books[4] = new Book("The Girl on the Train", "Paula Hawkins", 2015, 15.00);
Console.WriteLine("Here are the available books:");
for (int i = 0; i < books.Length; i++)
Console.WriteLine($"{i + 1}. {books[i].Title} by {books[i].Author} - ${books[i].Price:F2}");
Console.WriteLine("Enter the book number to add to cart:");
int bookNumber = Convert.ToInt32(Console.ReadLine());
if (bookNumber >= 1 && bookNumber <= 5)
Console.WriteLine("Enter the quantity:");
int quantity = Convert.ToInt32(Console.ReadLine());
total += books[bookNumber - 1].Price * quantity;
Console.WriteLine("Book(s) added to cart! \n");
Console.WriteLine("Welcome to the bookstore!");
Console.WriteLine("Select an item to buy: \n [1] Books \n [2] Pencils \n [3] View Books \n [4] Bookmarks \n [5] Checkout");
Console.WriteLine("Invalid book number");
Console.WriteLine("How many pencils would you like to buy?");
int quantity = Convert.ToInt32(Console.ReadLine());
total += quantity * 1.00;
Console.WriteLine($"Pencil(s) added to the cart! \n ");
Console.WriteLine("Welcome to the bookstore!");
Console.WriteLine("Select an item to buy: \n [1] Books \n [2] Pencils \n [3] View Books \n [4] Bookmarks \n [5] Checkout");
Book[] books = new Book[5];
books[0] = new Book("The Great Gatsby", "F. Scott Fitzgerald", 1925);
books[1] = new Book("The Hunger Games, Catching Fire", "Suzan Collins", 2009);
books[2] = new Book("Fifty Shades Of Grey", "E.L James", 2011);
books[3] = new Book("1984", "George Orwell", 1949);
books[4] = new Book("The Girl on the Train", "Paula Hawkins", 2015);
Console.WriteLine("Available books:");
for (int i = 0; i < books.Length; i++)
Console.WriteLine($"{i + 1}. {books[i].Title} by {books[i].Author}");
static void BuyBookmarks()
Console.WriteLine("How many bookmarks would you like to buy?");
int quantity = Convert.ToInt32(Console.ReadLine());
total += quantity * 2.00;
Console.WriteLine($"Bookmarks added to cart! \n");
Console.WriteLine("Welcome to the bookstore!");
Console.WriteLine("Select an item to buy: \n [1] Books \n [2] Pencils \n [3] View Books \n [4] Bookmarks \n [5] Checkout");
Console.WriteLine($"Total due: ${total:F2}");
Console.WriteLine("Please enter the amount of dollars: ");
double payment = Convert.ToDouble(Console.ReadLine());
Console.WriteLine("Insufficient payment. Please provide enough funds.");
double change = payment - total;
Console.WriteLine($"Your change is: ${change:F2}");
Console.WriteLine("Thank you for shopping with us!");