Answer to Question #188976 in C# for CHANDRASENA REDDY

Question #188976

Create a Class named BooksDemo accepts and displays the details of books using multidimensional array.


BOOKDemo:-

colName: String[4] = {"Book title", "Author", "Publisher", "Price"}

bookDetails: String[2, 4]

____________________

+Main(args: string[])


1
Expert's answer
2021-05-09T06:25:57-0400
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;


namespace C_SHARP
{
    class BooksDemo
    {
        public String[] colName = { "Book title", "Author", "Publisher", "Price" };
        public String[,] bookDetails = new string[2, 4];


        static void Main(string[] args)
        {
            BooksDemo books_demo = new BooksDemo();
            for (int d = 0; d < 2; d++)
            {
                for (int c = 0; c < books_demo.colName.Length; c++)
                {
                    Console.Write("Enter {0}: ", books_demo.colName[c].ToLower());
                    books_demo.bookDetails[d, c] = Console.ReadLine();
                }
                Console.WriteLine();
            }
            for (int d = 0; d < 2; d++)
            {
                for (int c = 0; c < books_demo.colName.Length; c++)
                {
                    Console.Write("{0}: {1}\n", books_demo.colName[c], books_demo.bookDetails[d, c]);
                }
                Console.WriteLine();
            }


            Console.ReadKey();
        }
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS