C Sharp Homework Help, Project Help, C Sharp Assignment Solution

We can help with C# programming assignments, if you need personal online tutoring in C# or any other programming language.

C# is Microsoft’s answer to Java after Sun stopped Microsoft from modifying Java for Windows. It works with Visual
Studio, and so it can be used to write GUI programs easier than in Java. It also has extra features not supported in
Java, such as operator overloading, low level access. It works with Microsoft’s .NETCLR although there is a portable
version called Mono.

C# is a modern programming language used for the development of various software applications. ProgrammingHomeworkHelp offers C sharp assignment solutions. Our experts deliver C sharp programming homework help the students to know the basics like it is an object-oriented, general-purpose programming language, which is created and developed by Microsoft and organized with the .NET platform. The software is developed with high variety with C# and on the .NET platform as office applications, web applications, desktop applications, websites, games, mobile applications and many others. C# is a high-level language similar to C++ and Java. Also, the languages like Delphi, VB.NET and C are also similar to this language.

C# is a modern, general-purpose, object-oriented programming language. Students study about the features and different components of C#. Their problem starts when they start solving c# assignments. C# is designed for Common Language Infrastructure (CLI), which contains the executable code and runtime environment.

If you need a solution for your C# home work, then we can provide it. See the following example C# problem solutions.

Phone prices

Call Data Records are text files provided by telephone systems detailing the time, duration, and destination of any calls that have been made. Rated Call Data Records are the same records provided to a client, with the addition of an area code name, a connection charge, a cost per minute and a total cost for each call. These are typically referred to as an itemised bill by phone providers.

Calls are rated by matching the prefix of a phone number to an area code. Each area code has a connection charge and a per-minute cost, both given in pence. By multiplying the length of the call by the per-minute charge and adding the connection charge it is possible to calculate the cost of an individual call.

Area code rates are given in the table below:

Area Code Prefix Connection Charge (pence) Per Minute Cost (pence)
Domestic 02 or 03 0 0.5
Mobile 07 0 5.5
International 00 5 11.3

Because these charges can be very small the rounding system that is used can have a big difference. The length of calls ought to be rounded up to the nearest minute, and the total cost of the calls ought to be rounded up to the nearest penny.

The task is to write an application that reads in an unrated CDR and prints a rated CDR to the screen. CDRs will be provided as a CSV file with the following columns:

  • Call start date and time.
  • Duration in seconds.
  • Destination number.

The Rated CDR should be printed with the following columns:

  • Time of call.
  • Duration in seconds.
  • Destination number.
  • Name of area code.
  • Connection charge (in pence).
  • Per-minute cost (in pence).
  • Total cost (in pounds and pence).

Example Input:

2010-11-15 20:02:04,34,02072221234 
2010-11-15 20:06:30,171,001145532411 
2010-11-15 21:11:22,1344,02072221234 
2010-11-15 21:44:51,34,07707544869 
2010-11-15 22:01:09,248,07707544869

Example Output:

Time of call Duration Destination Area code Connection PPM Total
2010-11-15 20:02:04 34 02072221234 Domestic 0p 0.5p 0.01
2010-11-15 20:06:30 171 001145532411 International 5p 11.3p 0.39
2010-11-15 21:11:22 1344 02072221234 Domestic 0p 0.5p 0.12
2010-11-15 21:44:51 34 07707544869 Mobile 0p 5.5p 0.06
2010-11-15 22:01:09 248 07707544869 Mobile 0p 5.5p 0.28

This is a C# assignment, you can see the nature of the work. So if you need help with C# project or just need a C# online tutor to help you, we can do that.

Experts discuss about Automatic Garbage Collection, Standard Library, Assembly Versioning, Properties and Events when they offer C# programming assignment help. Students seek help with c# homework to solve questions on Delegates and Events Management, Easy-to-use Generics, and Indexers.

Experts provide C sharp programming assignment help to the students so that they can learn that all C# programs are object-oriented and consist of a set of definitions in the form of classes that contain methods, which further contain the programming logic which is the instructions the computer executes.

Object differences

The task is to create a component that can work out the differences between two objects. This sort of object would typically be used in audit scenarios. We want this component to do the following:

  • Compare two instances of the same type and return a list of the differences
  • You only need to compare public properties
  • Items in the list should be formatted appropriately for their data type (see example below).
  • You won′t know the data type of the objects at compile time – your solution should work with any class we might
    create now or in the future.
  • Properties can be user-defined types, not just built in strings, ints, etc.
  • Only properties that have changed should be shown in the list
  • The name of the property should be included in each difference, appropriately formatted, e.g. “Date of Birth” rather than “DateOfBirth”

Example Usage

// Your solution should work with any type 
var myFirstOb = new SomeType(); 
myFirstOb.Forename = {"David"}; 
myFirstOb.DateOfBirth = new DateTime(1990, 5, 2); 
myFirstOb.SpecialNumber = 23; 
var mySecondOb = new SomeType(); 
mySecondOb.Forename = {"Janet"}; 
mySecondOb.DateOfBirth = new DateTime(2000, 11, 22); 
mySecondOb.SpecialNumber = 23;

// GetChanges is static here, but your implementation doesn{'}t need to be 
List<string> differences = Auditor.GetChanges(myFirstOb, mySecondOb);

Expected Result

Assert.Equals(2, differences.Length); 
Assert.Equals(differences[0] ,{"Forename changed from David to Janet"}); 
Assert.Equals(differences[1] ,{"Date Of Birth changed from 02/May/1990 to 22/Nov/2000"});

Our experts provide full support to students on c# homework assignments. Our tutors offer c# programming homework help to the beginners to clear the concepts of C sharp. Also, the beginners find c# assignments very useful as they can avail the benefits of C# assignment questions and answers.

Problem 3

Test application

Your employer has an existing system for employees to submit booking requests for meetings in the boardroom. Your employer has now asked you to implement a system for processing batches of booking requests.

Input

Your processing system must process input as text. The first line of the input text represents the company office hours, in 24 hour clock format, and the remainder of the input represents individual booking requests. Each booking request is in the following format.

[request submission time, in the format YYYY-MM-DD HH:MM:SS] [ARCH:employee id]
[meeting start time, in the format YYYY-MM-DD HH:MM] [ARCH:meeting duration in hours]

A sample text input follows, to be used in your solution.

Input

0900 1730
2011-03-17 10:17:06 EMP001
2011-03-21 09:00 2
2011-03-16 12:34:56 EMP002
2011-03-21 09:00 2
2011-03-16 09:28:23 EMP003
2011-03-22 14:00 2
2011-03-17 11:23:45 EMP004
2011-03-22 16:00 1
2011-03-15 17:29:12 EMP005
2011-03-21 16:00 3

Output

Your system must provide a successful booking calendar as output, with bookings being grouped chronologically by day. For the sample input displayed above, your system must provide the following output.

Output

2011-03-21
09:00 11:00 EMP002
2011-03-22
14:00 16:00 EMP003
16:00 17:00 EMP004

Constraints

No part of a meeting may fall outside office hours.

Meetings may not overlap.

The booking submission system only allows one submission at a time, so submission times are guaranteed to be unique.

Bookings must be processed in the chronological order in which they were submitted.

The ordering of booking submissions in the supplied input is not guaranteed.

Notes

The current requirements make no provision for alerting users of failed bookings; it is up to the user to confirm that their booking was successful.

Although the system that you produce may open and parse a text file for input, this is not part of the requirements. As long as the input text is in the correct format, the method of input is up to the developer.

Solution

Problem 1

using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;

namespace P1
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            // ask the user to input the path of the data record
            Console.Write("Enter the path of the call data records file: ");
            string filename = Console.ReadLine();
            filename = filename.Trim();

            if (filename.Length == 0)
            {
                Console.WriteLine("Error: the file path is empty!");
                Console.WriteLine("Press Enter to quit.");
                Console.ReadLine();
                return;
            }

            // now read all lines from the text file
            IEnumerable<string> lines = new string[0];

            try
            {
                lines = System.IO.File.ReadLines(filename);
            }
            catch (Exception e)
            {
                Console.WriteLine("Error: could not process file {0}", filename);
                Console.WriteLine("Press Enter to quit.");
                Console.ReadLine();
                return;
            }

            // print the header of the table
            Console.WriteLine("{0} | {1} | {2,12} | {3,13} | {4} | {5,5} | {6}", 
                "Time of call       ", "Durt", "Destination", "Area code", "C ", "PPM", "Total");

            // process each line
            foreach (string line in lines)
            {
                // split the line into different parts, and remove "" in each part
                string[] parts = line.Split(new char[] {','});
                for (int i = 0; i < parts.Length; i++)
                {
                    parts[i] = parts[i].Substring(1, parts[i].Length - 2); // remove ""
                }

                string time = parts[0];
                int duration = int.Parse(parts[1]);
                string destination = parts[2];
                string area = "";
                int connection = 0; // connection charge
                double ppm = 0; // per minute cost
                double total = 0; // total cost

                // calculate area code
                if (destination.StartsWith("02") || destination.StartsWith("03"))
                {
                    area = "Domestic";
                    connection = 0;
                    ppm = 0.5;
                }
                if (destination.StartsWith("07"))
                {
                    area = "Mobile";
                    connection = 0;
                    ppm = 5.5;
                }
                if (destination.StartsWith("00"))
                {
                    area = "International";
                    connection = 5;
                    ppm = 11.3;
                }

                // calculate total cost
                total = connection;
                total = connection + duration / 60 * ppm;
                if (duration % 60 != 0)
                {
                    total += ppm;
                }

                total = total / 100; // convert to pounds and pence

                Console.WriteLine("{0} | {1,4} | {2,12} | {3,13} | {4}p | {5,4}p | {6:F}",
                    time, duration, destination, area, connection, ppm, total);
            }

            Console.WriteLine();
            Console.WriteLine("Press Enter to quit.");
            Console.ReadLine();
        }
    }
}

We have got really good feedback for our c# programming assignments. Students always get full time support from our tutors and their assignments being solved on time by our c# programming expert.

Problem 2

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;

namespace P2
{
    class Auditor
    {
        // a function to convert property name into a human readable string
        // for example, DateOfBirth -> Date Of Birth
        private static string ConvertPropertyName(string original)
        {
            string result = "";
            foreach (char letter in original)
            {
                if (Char.IsUpper(letter))
                {
                    // add a space before the upper case letters
                    result += " ";
                }
                result += letter;
            }
            if (result.StartsWith(" "))
            {
                result = result.Substring(1);
            }
            return result;
        }

        // a helper function that converts the object into its string representation
        private static string represent(object value)
        {
            // more type to string conversion can be added here
            return value.ToString();
        }

        /// <summary>
        /// return a list of differences between two objects of the same type.
        /// throws 
        /// </summary>
        /// <param name="left">the old object</param>
        /// <param name="right">the new object</param>
        /// <returns>a list of differences </returns>
        public static List<string> GetChanges(object left, object right)
        {
            if (left == null || right == null)
            {
                throw new ArgumentNullException();
            }

            Type type = left.GetType();

            if (type != right.GetType())
            {
                throw new InvalidOperationException("could not compare objects with different type");
            }

            List<string> differences = new List<string>();

            // get public property infos
            PropertyInfo[] properties = type.GetProperties();

            foreach (PropertyInfo property in properties)
            {
                string name = ConvertPropertyName(property.Name);

                // only compare properties that has no arguments required to get from
                var p1 = property.GetValue(left, new object[0]);
                var p2 = property.GetValue(right, new object[0]);

                if (!p1.Equals(p2))
                {
                    string diff = string.Format("{0} changed from '{1}' to '{2}'",
                        name, represent(p1), represent(p2));

                    differences.Add(diff);
                }    
            }

            return differences;
        }
    }

    class People
    {
        public string Forename { get; set; }
        public DateTime DateOfBirth { get; set; }
        public int SpecialNumber { get; set; }
    }

    class Program
    {
        static void Main(string[] args)
        {
            // a test program 
            var myFirstOb = new People(); 
            myFirstOb.Forename = "David"; 
            myFirstOb.DateOfBirth = new DateTime(1990, 5, 2); 
            myFirstOb.SpecialNumber = 23;

            var mySecondOb = new People();

            mySecondOb.Forename = "Janet";
            mySecondOb.DateOfBirth = new DateTime(2000, 11, 22); 
            mySecondOb.SpecialNumber = 23;

            // GetChanges is static here, but your implementation doesn{'}t need to be 
            List<string> differences = Auditor.GetChanges(myFirstOb, mySecondOb);

            Console.WriteLine("{0} differences.", differences.Count);
            foreach (string difference in differences)
            {
                Console.WriteLine(difference);
            }

            Console.WriteLine();
            Console.WriteLine("Press Enter to quit.");
            Console.ReadLine();

        }
    }
}

Problem 3

Program.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using BookingSystem;

namespace P3
{
    class Program
    {
        // a test program for the Booking module
        // since file IO is not required, we add some bookings by code.
        static void Main(string[] args)
        {
            // 1. create a booking scheduler
            BookingScheduler scheduler = new BookingScheduler("0900", "1730");

            // 2. add bookings to the scheduler
            Booking b1 = new Booking(DateTime.Parse("2011-03-17 10:17:06"), "EMP001", DateTime.Parse("2011-03-21 09:00"), 2);
            Booking b2 = new Booking(DateTime.Parse("2011-03-16 12:34:56"), "EMP002", DateTime.Parse("2011-03-21 09:00"), 2);
            Booking b3 = new Booking(DateTime.Parse("2011-03-16 09:28:23"), "EMP003", DateTime.Parse("2011-03-22 14:00"), 2);
            Booking b4 = new Booking(DateTime.Parse("2011-03-17 11:23:45"), "EMP004", DateTime.Parse("2011-03-22 16:00"), 1);
            Booking b5 = new Booking(DateTime.Parse("2011-03-15 17:29:12"), "EMP005", DateTime.Parse("2011-03-21 16:00"), 3);

            scheduler.AddBooking(b1);
            scheduler.AddBooking(b2);
            scheduler.AddBooking(b3);
            scheduler.AddBooking(b4);
            scheduler.AddBooking(b5);

            // 3. schedule
            Schedule[] schedules = scheduler.Scheduling();

            // 4. print the result
            foreach (Schedule schedule in schedules)
            {
                Console.WriteLine(schedule.ToString());
            }

            Console.WriteLine();
            Console.WriteLine("Press Enter to quit.");
            Console.ReadLine();
        }
    }
}

We at programming homework help also provide live c# help to the learners where they find solutions for several assignment questions related to Simple Multithreading, LINQ and Lambda Expressions, Integration with Windows.

Booking.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

/// the booking system module
/// To use this module to generate a schedule, follow this steps:
///     1) create a BookingScheduler 
///     2) add a group of booking request to the scheduler
///     3) generate the schedule
namespace BookingSystem
{
    public static class DateTimeExtensions
    {
        /// <summary>
        /// entend this existing DateTime class to check whether 
        /// the time is between the start and end period, considering only hour and minute fields in datetime.
        /// </summary>
        /// <param name="time"></param>
        /// <param name="start"></param>
        /// <param name="end"></param>
        /// <returns></returns>
        public static bool Between(this DateTime time, TimeSpan start, TimeSpan end)
        {
            return start <= time.TimeOfDay && time.TimeOfDay <= end;
        }
    }

    public class Booking
    {
        /// <summary>
        /// When is this booking requested?
        /// </summary>
        public DateTime RequestTime { get; private set; }

        /// <summary>
        /// the employee that has made this request.
        /// </summary>
        public string Employee { get;private set; }

        /// <summary>
        /// the start time of this reservation
        /// </summary>
        public DateTime Start { get; private set; }

        /// <summary>
        /// the end time of this reservation
        /// </summary>
        public DateTime End { get; private set; }

        /// <summary>
        /// Construct a booking object.
        /// </summary>
        /// <param name="requestTime"></param>
        /// <param name="employee"></param>
        /// <param name="reserveTime"></param>
        /// <param name="duration"></param>
        public Booking(DateTime requestTime, string employee, DateTime reserveTime, int duration)
        {
            this.RequestTime = requestTime;
            this.Employee = employee;
            this.Start = reserveTime;
            this.End = reserveTime.AddHours(duration);
        }
    }

    /// <summary>
    /// a schedule class that groups valid schedule in the same together.
    /// this object is generated by the BookingScheduler.Scheduling method
    /// </summary>
    public class Schedule
    {
        /// <summary>
        /// the date of this schedule
        /// </summary>
        public DateTime Date { get; private set; }

        /// <summary>
        /// this bookings on this day
        /// </summary>
        public List<Booking> Bookings { get; private set; }

        public Schedule(DateTime date)
        {
            this.Date = date.Date;
            this.Bookings = new List<Booking>();
        }

        /// <summary>
        /// add a schedule on this day, return true if added succesfully
        /// otherwise if any time conflicts happen, return false.
        /// </summary>
        /// <param name="booking"></param>
        public bool Add(Booking booking)
        {
            // check conflicts
            foreach (Booking exist in Bookings)
            {

                if (booking.Start.TimeOfDay < exist.End.TimeOfDay && booking.End.TimeOfDay > exist.Start.TimeOfDay)
                {
                    return false;
                }
            }

            this.Bookings.Add(booking);
            return true;
        }

        /// <summary>
        /// construct a string reprensentation of this schedule
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            StringBuilder builder = new StringBuilder();
            builder.AppendFormat("{0}n", Date.ToString("yyyy-MM-dd"));

            foreach (Booking booking in Bookings.OrderBy(x => x.Start))
            {
                builder.AppendFormat("{0} {1} {2}n",
                    booking.Start.ToString("HH:mm"), booking.End.ToString("HH:mm"), booking.Employee);
            }
            return builder.ToString();
        }
    }

    public class BookingScheduler
    {
        /// <summary>
        /// the start time of the office.
        /// Only the hour:minutes part is used.
        /// </summary>
        public TimeSpan OfficeStart { get; private set; }

        /// <summary>
        /// the end time of the office.
        /// Only the hour:minutes part is used.
        /// </summary>
        public TimeSpan OfficeEnd { get; private set; }

        /// <summary>
        /// construct a booking system for the given office hours.
        /// The start and end office hours should be in format: HHMM in 24hours.
        /// </summary>
        /// <param name="start"></param>
        /// <param name="end"></param>
        public BookingScheduler(string start, string end)
        {
            int hour1 = int.Parse(start.Substring(0, 2));
            int minute1 = int.Parse(start.Substring(2));
            int hour2 = int.Parse(end.Substring(0, 2));
            int minute2 = int.Parse(end.Substring(2));

            this.OfficeStart = new TimeSpan(hour1, minute1, 0);
            this.OfficeEnd = new TimeSpan(hour2, minute2, 0);            
        }

        private List<Booking> bookings = new List<Booking>();

        /// <summary>
        /// add a booking request to the system.
        /// </summary>
        /// <param name="booking"></param>
        /// <returns>a boolean value to indicate whether this booking has been added into the system</returns>
        public bool AddBooking(Booking booking)
        {
            // make sure the booking is in the period of office hours
            if (!booking.Start.Between(this.OfficeStart, this.OfficeEnd) ||
                !booking.End.Between(this.OfficeStart, this.OfficeEnd))
            {
                return false;
            }

            bookings.Add(booking);
            return true;
        }

        public Schedule[] Scheduling()
        {
            // first sort bookings ascendingly to their requested date
            IOrderedEnumerable<Booking> requests = this.bookings.OrderBy(x => x.RequestTime);

            Dictionary<DateTime, Schedule> schedules = new Dictionary<DateTime, Schedule>();

            foreach (Booking booking in requests)
            {
                // add a new schedule for this date if not exist yet
                if (!schedules.ContainsKey(booking.Start.Date))
                {
                    schedules[booking.Start.Date] = new Schedule(booking.Start.Date);
                }
                // add this request to the schedule
                schedules[booking.Start.Date].Add(booking);
            }

            // return the schedule in ascending order
            Schedule[] result = schedules.Values.OrderBy(x => x.Date).ToArray<Schedule>();
            return result;
        }
    }
}

As a demonstration of a C# project, this demonstrates the type of solution we can offer.

Mixing colors

Create an application that lets the users to provide two primary colors and then display the name of the produced secondary color. Your app should provide the following functionalities:

Users are prompted to provide two primary colors (by typing red, blue, or yellow directly in a console window)

If a user provides two different primary colors, display the name of the secondary color that will be produced based on the rules above

If a user provide the same primary color twice (such as red /red or blue / blue), display the name of this primary color back as the result (so, for example, mixing red and red will make red)

If a user provide anything other than any of the three primary colors (i.e., his input is not any one of red, blue,
or yellow), display an error message and ask the user to input a valid primary color again (and assume he will do
it right for the second time).

You are expected to write a class called ColorMixer that encapsulates this color mixing process in a method. Then,
assume that one of your colleagues are going to test your class by using the following unfinished codes. Please help
him finish the codes (but don′t change existing codes) and include them in your own program to test your ColorMixer class.

class ColorMixerTest
{
    static void Main(string[] args)
    {
        String firstColor, secondColor, mixedColor;

        Console.Write("Please input the first primary color as red, blue, or yellow: ");
        firstColor = Console.ReadLine();

        /*** Insert some codes here to check the validity of the first color; 
            Ask users to input again (for one more time only) if the previous input is not red, blue, or yellow
        ***/

        Console.Write("Please input the second primary color as red, blue, or yellow: ");
        secondColor = Console.ReadLine();

        /*** Insert some codes here to check the validity of the second color; 
            Ask users to input again (for one more time only) if the previous input is not red, blue, or yellow
        ***/

        ColorMixer cm = new ColorMixer();
        mixedColor = cm.mix(firstColor, secondColor);
        Console.WriteLine("The color produced by mixing these two colors is: " + mixedColor);

    }
}

Solution

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class ColorMixer
{
    // All of the possible colors
    private static string[] colors = { "white", "red", "blue", "purple", "yellow", "orange", "green", "black" };
    public ColorMixer() {}

    // The colors are arranged by order of color (so we can just or values together to combine them)
    private static int asBits(string color)
    {
        for (int i = 0; i < 8; i++)     //go through each color
            if (color == colors[i]) return i;   //is this the color we wanted?
        return 0;                       //return white if not found
    }

    // Check if the color is one of the primary colors
    public static bool valid(string color)
    {
        int colval = asBits(color);
        return colval == 1 || colval == 2 || colval == 4;       //red, blue, yellow
    }

    // Mix 2 colors
    public string mix(string firstColor, string secondColor)
    {
        //red | yellow = orange
        //blue | yellow = green
        //red | blue = purple
        //red | green = black   (can only enter this on second try since green is not allowed)
        //red | red = red, etc
        return colors[asBits(firstColor) | asBits(secondColor)];
    }
}

Following you should find a sample C# home work, I’ve had to provide multiple versions of assignments, and can alter the code to match your style.

Retail price calculator

Create a C♯; GUI application that lets the user enter an item′s wholesale cot and its mark-up percentage. It should
then display the item′s retail price. For Example

  • If an item′s wholesale cost is $5.00 and mark-up percentage is 100 percent, then the item′s price is $10.00.
  • If an item′s wholesale cost is $5.00 and mark-up percentage is 50 percent, then the item′s price is $7.50.

The program should have a method named calculateRetail that receives the wholesale cost and the mark-up percentage
as arguments and returns the retail price of the item.

Falling Distance

When an object is falling because of gravity, the following formula can be used to determine the distance the object
falls in a specific time period: d=½(g*t2)

The variables in the formula are as follows: d is the distance in meters, g is 9.8, and t is amount of time in seconds
that the object has been falling.

Create a C# GUI application that allows the user to enter amount of time object has fallen and then displays the distance that the object fell. The application should have a function named falling D istance. The falling Distance function should accept an object′s falling time in seconds as an argument. The function should return the distance in meters that the object has fallen during the time interval.

One of the most popular programming languages is C# and it is being used by many developers worldwide. Since C# is developed by Microsoft, development and execution of applications happens in the .NET Framework, which is widely spread among Microsoft-oriented companies, the different organizations and also the individual developers. C# language and the .NET platform are not open to third parties and are maintained and managed entirely by Microsoft. Because of this, all other large software corporations like IBM, Oracle and SAP have developed their own software products by using Java as their primary language. Besides C#  homework help, we also provide assignment help in java.

Students have always find our c# assignment help to be very useful as their assignment questions are readily solved with proper explanations and comments are also updated which gives a great understanding of the code solution.

Solution – Retail price calculator

RetailPriceCalculator.cs

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace RetailPriceCalculator
{
    public partial class RetailPriceCalculator : Form
    {
        public RetailPriceCalculator()
        {
            InitializeComponent();
        }

        private void costText_TextPressed(object sender, KeyPressEventArgs e)
        {
            // only allow digits and one decimal point
            if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar) && e.KeyChar != '.')
            {
                e.Handled = true;
            }

            if (e.KeyChar == '.' && (sender as TextBox).Text.IndexOf('.') > -1)
            {
                e.Handled = true;
            }
        }

        private void calculateEvent()
        {
            // get the input values from the text fields
            double cost = 0;
            double percent = 0;
            if (!Double.TryParse(this.costText.Text, out cost) ||
                !Double.TryParse(this.markupText.Text, out percent))
            {
                this.resultText.Text = "";
            }
            else
            {
                double result = calculateRetail(cost, percent);
                this.resultText.Text = result.ToString();
            }

        }

        public double calculateRetail(double wholesale, double markup)
        {
            return wholesale * (1 + markup / 100);
        }

        private void text_TextChanged(object sender, EventArgs e)
        {
            calculateEvent();
        }
    }
}

Solution – Falling distance

FallingDistance.cs

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace FallingDistance
{
    public partial class FallingDistance : Form
    {
        public FallingDistance()
        {
            InitializeComponent();
        }

        private void timeText_TextChanged(object sender, EventArgs e)
        {
            // get the input values from the text fields
            double time = 0;
            if (!Double.TryParse(this.timeText.Text, out time))
            {
                this.resultText.Text = "";
            }
            else
            {
                double result = fallingDistance(time);
                this.resultText.Text = result.ToString();
            }
        }

        public double fallingDistance(double time)
        {
            double g = 9.8;
            return 1.0 / 2 * g * time * time;
        }

        private void text_TextPressed(object sender, KeyPressEventArgs e)
        {
            // only allow digits and one decimal point
            if (!char.IsControl(e.KeyChar) && !char.IsDigit(e.KeyChar) && e.KeyChar != '.')
            {
                e.Handled = true;
            }

            if (e.KeyChar == '.' && (sender as TextBox).Text.IndexOf('.') > -1)
            {
                e.Handled = true;
            }
        }
    }
}

Here is a sample of a C# home work, compare our solutions to any others. Check out our C# programming homework help.

The Java language is open-source and an entire community of software companies, individual developers and organizations participate. The specifications, the standards and all the new features of Java developed by workgroups and formed by the entire Java community, rather than a single company as compared to C# and .NET Framework. You can contact us for online C# assignment help and get simple, well commented code which is easy to understand.

Other areas are Common Type System, Metadata and Assemblies, Windows Forms, ASP.Net and ASP.Net AJAX from where learners get most of the assignment problems and they are again in search of c# homework help.

Bank account

For this task, you are required to prepare a UML class diagram with the following features:

  • Illustrates the classes representing different account types in the system, in particular the Account,
    CashAccount, CreditCard, Loan, and Mortgage classes;
  • Illustrates the classes representing different users in the system, in particular the User, Administrator,
    Customer, Manager, and Teller classes; Note: you do not need to illustrate the attributes, properties, and
    methods for the classes representing different users in the system, i.e., just illustrate these classes with
    a single box containing the class name.
  • Illustrates the relationships between these classes, including any variable names and multiplicity; and
  • Illustrates the attributes, properties, and methods for all classes (except for those representing users
    as indicated above.

For this task you are required to extend the provided code to achieve the following functionality:

  • Modify the Account class as follows:
    • Have an opening balance attribute and property;
    • Record a list of transactions:
    • Define a Transaction class for this purpose;
    • Do not worry about types of transaction, allow the Transaction class to store positive and negative values;
    • Modify the Balance property to calculate the balance from the opening balance plus the value of recorded transactions.
  • Modify the Teller′s ability to open a cash account to allow for the opening balance to be specified;
  • Add a new menu option for the Teller to be able to list all accounts for a customer:
    • The teller is given a list of customers to select from;
    • The information about the customer is displayed;
    • For each account the customer holds:
      -?Display the account summary; and
      -?Display each transaction.

Solution

Account.cs

using System;

namespace Project_2
{
    public abstract class Account : IMenus
    {
        private User _Owner;

        //Define Transaction class
        private Transaction _Transaction;

         static void Main()
        {
        List<Transaction> Tlist = new List<Transaction>();
        Tlist.Add(Tlist.get(_Ttype[0]));
        Tlist.Add(Tlist.get(_Ttype[1]));

        }

        public User Owner
        {
            get { return _Owner; }
            set { _Owner = value; }
        }

        private uint _Number;
        public uint Number
        {
            get { return _Number; }
            set { _Number = value; }
        }

        private decimal _Balance;
        public decimal Balance
        {
            get { return _Balance+_OpenBalance; }
        }

    //Have an opening balance attribute and property
    private decimal _OpenBalance;
        public decimal OpenBalance
        {
            get { return _OpenBalance; }
             set { _OpenBalance = value; }
        }

        private Teller _Teller;
        public Teller Teller
        {
            get { return _Teller; }
        }

        protected void IncreaseBalance(decimal amount)
        {
            _Balance += amount;
        }

        protected void DecreaseBalance(decimal amount)
        {
            _Balance -= amount;
        }

        public Account(Teller teller, uint number, decimal balance)
        {
            _Teller = teller;
            _Number = number;
            _Balance = balance;
        }

        public override string ToString()
        {
            return string.Format("Account #{0}: {1:c} (Opened by {2})", _Number, _Balance, _Teller);
        }

        #region IMenus Members

        public abstract string MenuName { get; }
        public abstract MenuOption[] MenuOpts { get; }

        #endregion
    }
}

AccountManager.cs

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;

namespace Project_2
{
    public static class AccountManager
    {
        private static uint _NextAccountNumber = (uint)DateTime.Now.Year * 1000000U + (uint)DateTime.Now.Month * 10000U + 1U;

        private static List<Account> _Accounts = new List<Account>();
        public static ReadOnlyCollection<Account> AccountList
        {
            get { return AccountManager._Accounts.AsReadOnly(); }
        }

        private static void ConfirmUserExists(Customer person)
        {
            if (UserManager.Find(person.Login) == null)
                throw new NoSuchUserException();
        }

        public static void OpenCashAccount(Teller teller, Customer person)
        {
            ConfirmUserExists(person);
            CashAccount ca = new CashAccount(teller, _NextAccountNumber++);
            ca.Owner = person;
            person.AddAccount(ca);
            _Accounts.Add(ca);
        }

        public static void OpenCreditCardAccount(Teller teller, Customer person, decimal limit)
        {
            ConfirmUserExists(person);
            CreditCard cc = new CreditCard(teller, _NextAccountNumber++, limit);
            cc.Owner = person;
            person.AddAccount(cc);
            _Accounts.Add(cc);
        }

        public static void OpenMortgageAccount(Teller teller, Customer person)
        {
            ConfirmUserExists(person);
            Mortgage ma = new Mortgage(teller, _NextAccountNumber++);
            ma.Owner = person;
            person.AddAccount(ma);
            _Accounts.Add(ma);
        }

        public static void DeleteAccounts(User person)
        {
            List<Account> tmp = _Accounts;
            _Accounts = new List<Account>();

            foreach (Account acct in tmp)
            {
                if (acct.Owner.Login != person.Login)
                    _Accounts.Add(acct);
            }
        }
    }
}

Administrator.cs

using System;

namespace Project_2
{
    public class Administrator : User
    {
        public Administrator(string givenNames, string familyName, string login, string password)
            : base(givenNames, familyName, login, password)
        {
        }

        public void CreateManager()
        {
            string familyName;
            string givenNames;
            string login;
            string password;

            Console.Write("Enter family name: ");
            familyName = Console.ReadLine();

            Console.Write("Enter given names: ");
            givenNames = Console.ReadLine();

            Console.Write("Enter login name: ");
            login = Console.ReadLine();

            Console.Write("Enter password: ");
            password = Console.ReadLine();

            try
            {
                UserManager.Add(new Manager(givenNames, familyName, login, password));
            }
            catch (Exception e)
            {
                Console.Error.WriteLine("Error: {0}", e);
            }
        }

        public void ListUsers()
        {
            Console.WriteLine("User list:n==========");
            foreach (string login in UserManager.UserList)
            {
                Console.WriteLine(UserManager.Find(login));
            }
        }

        public void DeleteUser()
        {
            Console.Write("Delete which user? ");

            User usr = UserManager.Find(Console.ReadLine());
            if (usr == null)
                Console.Error.WriteLine("No such user registered");
            else
            {
                AccountManager.DeleteAccounts(usr);
                UserManager.Delete(usr.Login);
            }
        }

        protected override void ChangePassword()
        {
            Console.Write("Enter username: ");
            string login = Console.ReadLine();
            Console.Write("Please enter new password: ");
            string newPass = Console.ReadLine();

            User u = UserManager.Find(login);
            if (u == null || UserManager.ChangePassword(login, u.Password, newPass) == false)
                Console.WriteLine("Password change failed.");
            else
                Console.WriteLine("Password change succeeded.");
        }

        public override string ToString()
        {
            return string.Format("Administrator {0}", base.ToString());
        }

        #region IMenus Members

        public override string MenuName
        {
            get { return "Administrator Menu"; }
        }

        public override MenuOption[] MenuOpts
        {
            get
            {
                return new MenuOption[] {
                    new MenuCustomOption("Create a new manager", CreateManager),
                    new MenuCustomOption("List the system users", ListUsers),
                    new MenuCustomOption("Delete a user", DeleteUser),
                    new MenuSpecialOption("Logout", MenuSpecialOption.OptionType.Logout, true),
                    new MenuSpecialOption("Exit", MenuSpecialOption.OptionType.Exit, true) 
                };
            }
        }

        #endregion
    }
}

Many new components are incorporated into C# are like Windows Workflow Foundation (WF), Windows Presentation Foundation, Windows Communication Foundation (WCF), LINQ.

BMSException.cs

using System;

namespace Project_2
{
    abstract class BMSException : Exception
    {
        public BMSException()
            : base()
        {
        }

        public BMSException(string message)
            : base(message)
        {
        }

        public BMSException(string message, Exception innerException)
            : base(message, innerException)
        {
        }
    }
}

CashAccount.cs

using System;

namespace Project_2
{
    public class CashAccount : Account
    {
        public virtual void Deposit(decimal amount)
        {
            base.IncreaseBalance(amount);
        }

        public virtual bool Withdrawal(decimal amount)
        {
            bool result = false;

            if (base.Balance >= amount)
            {
                base.DecreaseBalance(amount);
                result = true;
            }

            return result;
        }

        public CashAccount(Teller teller, uint number)
            : base(teller, number, 0.0M)
        {
        }

        public override string ToString()
        {
            return string.Format("Cash {0}", base.ToString());
        }

        public void DoDeposit()
        {
            Console.Write("Enter amount: ");
            decimal amount;
            while (decimal.TryParse(Console.ReadLine(), out amount) != true)
            {
                Console.Error.WriteLine("Invalid input.");
                Console.Write("Enter amount: ");
            }
            Deposit(amount);
        }

        public void DoWithdraw()
        {
            Console.Write("Enter amount: ");
            decimal amount;
            while (decimal.TryParse(Console.ReadLine(), out amount) != true)
            {
                Console.Error.WriteLine("Invalid input.");
                Console.Write("Enter amount: ");
            }
            if (Withdrawal(amount) == false)
                Console.Error.WriteLine("Transaction failed.");
        }

        #region IMenus Members

        public override string MenuName
        {
            get { return "Cash Account"; }
        }

        public override MenuOption[] MenuOpts
        {
            get
            {
                return new MenuOption[] {
                    new MenuCustomOption("Deposit", DoDeposit),
                    new MenuCustomOption("Withdraw", DoWithdraw),
                    new MenuSpecialOption("Exit", MenuSpecialOption.OptionType.Exit, true) 
                };
            }
        }

        #endregion
    }
}

CreditCard.cs

using System;

namespace Project_2
{
    public class CreditCard : Loan
    {
        public decimal GetLimit()
        {
            return base.Limit;
        }

        public void IncreaseLimit(decimal amount)
        {
            base.Limit += amount;
        }

        public bool DecreaseLimit(decimal amount)
        {
            bool result = false;

            if (amount <= base.Limit)
            {
                base.Limit -= amount;
                result = true;
            }

            return result;
        }

        public CreditCard(Teller teller, uint number, decimal limit)
            : base(teller, number, limit)
        {
        }

        public override string ToString()
        {
            return string.Format("Credit Card {0}", base.ToString());
        }

        public void PurchaseHandler()
        {
            Console.Write("Please enter the purchase value: ");
            decimal value = decimal.Parse(Console.ReadLine());
            if (base.Purchase(value) == false)
                Console.WriteLine("Purchase could not be processed.");
        }

        public void PaymentHandler()
        {
            Console.Write("Please enter the payment value: ");
            decimal value = decimal.Parse(Console.ReadLine());
            base.Payment(value);
        }

        #region IMenus Members

        public override string MenuName
        {
            get { return "Credit Card Menu"; }
        }

        public override MenuOption[] MenuOpts
        {
            get
            {
                return new MenuOption[] {
                    new MenuCustomOption("Purchase", PurchaseHandler),
                    new MenuCustomOption("Payment", PaymentHandler),
                    new MenuSpecialOption("Exit", MenuSpecialOption.OptionType.Exit, true)
                };
            }
        }

        #endregion
    }
}

Students generally have great difficulties in solving related problems and seek help with c# assignment. Our C# online experts also provide c# project help students to prepare project reports stepwise.

Customer.cs

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;

namespace Project_2
{
    public class Customer : User
    {
        public Customer(string givenNames, string familyName, string login, string password)
            : base(givenNames, familyName, login, password)
        {
        }

        private List<Account> _Accounts = new List<Account>();
        public ReadOnlyCollection<Account> Accounts
        {
            get { return _Accounts.AsReadOnly(); }
        }

        public void AddAccount(Account account)
        {
            _Accounts.Add(account);
        }

        public void ListAccounts()
        {
            Console.WriteLine("Accounts:n=========");
            foreach (Account acct in _Accounts)
            {
                Console.WriteLine(acct);
            }
        }

        public void SelectAccount()
        {
            string[] accts = new string[_Accounts.Count];

            for (int i = 0; i < _Accounts.Count; i++)
                accts[i] = _Accounts[i].ToString();

            uint which = MenuSubsystem.DoCancellableSubSelect("Select an account:", accts, "Selection: ");
            if (which > 0)
                MenuSubsystem.DoMenu(_Accounts[(int)which - 1]);
        }

        public override string ToString()
        {
            return string.Format("Customer {0}", base.ToString());
        }

        #region IMenus Members

        public override string MenuName
        {
            get { return "Customer Menu"; }
        }

        public override MenuOption[] MenuOpts
        {
            get
            {
                return new MenuOption[] {
                    new MenuCustomOption("List my accounts", ListAccounts),
                    new MenuCustomOption("Select an account", SelectAccount),
                    new MenuSpecialOption("Logout", MenuSpecialOption.OptionType.Logout, true),
                    new MenuSpecialOption("Exit", MenuSpecialOption.OptionType.Exit, true) 
                };
            }
        }

        #endregion
    }
}

IMenus.cs

using System;

namespace Project_2
{
    public interface IMenus
    {
        string MenuName { get; }
        MenuOption[] MenuOpts { get; }
    }
}

InvalidLoginException.cs

using System;

namespace Project_2
{
    class InvalidLoginException : BMSException
    {
        private const string DEFAULT_MESSAGE = "Invalid Login";

        public InvalidLoginException()
            : base(DEFAULT_MESSAGE)
        {
        }

        public InvalidLoginException(string message)
            : base(message)
        {
        }

        public InvalidLoginException(string message, Exception innerException)
            : base(message, innerException)
        {
        }
    }
}

Loan.cs

using System;

namespace Project_2
{
    public abstract class Loan : Account
    {
        private decimal _Limit;
        protected decimal Limit
        {
            get { return _Limit; }
            set { _Limit = value; }
        }

        public virtual bool Purchase(decimal value)
        {
            bool result = false;

            if (base.Balance + value <= _Limit)
            {
                base.IncreaseBalance(value);
                result = true;
            }

            return result;
        }

        public virtual void Payment(decimal value)
        {
            base.DecreaseBalance(value);
        }

        public Loan(Teller teller, uint number, decimal limit)
            : base(teller, number, 0.0M)
        {
            _Limit = limit;
        }

        public override string ToString()
        {
            return string.Format("{0} (Limit {1:c})", base.ToString(), _Limit);
        }
    }
}

Manager.cs

using System;
using System.Collections.Generic;

namespace Project_2
{
    public class Manager : User
    {
        public Manager(string givenNames, string familyName, string login, string password)
            : base(givenNames, familyName, login, password)
        {
        }

        public void CreateTeller()
        {
            string familyName;
            string givenNames;
            string login;
            string password;

            Console.Write("Enter family name: ");
            familyName = Console.ReadLine();

            Console.Write("Enter given names: ");
            givenNames = Console.ReadLine();

            Console.Write("Enter login name: ");
            login = Console.ReadLine();

            Console.Write("Enter password: ");
            password = Console.ReadLine();

            try
            {
                UserManager.Add(new Teller(givenNames, familyName, login, password));
            }
            catch (Exception e)
            {
                Console.Error.WriteLine("Error: {0}", e);
            }
        }

        public void ListAllAccounts()
        {
            Console.WriteLine("Accounts:n=========");
            foreach (Account acct in AccountManager.AccountList)
            {
                Console.WriteLine(acct);
            }
        }

        public void ListAllCustomers()
        {
            Console.WriteLine("Customers:n==========");
            foreach (User usr in UserManager.FilterLogins(typeof(Customer)))
            {
                Console.WriteLine(usr);
            }
        }

        public void ListAllTellers()
        {
            Console.WriteLine("Tellers:n========");
            foreach (User usr in UserManager.FilterLogins(typeof(Teller)))
            {
                Console.WriteLine(usr);
            }
        }

        private static Customer GetCustomerSelection()
        {
            List<User> customers = UserManager.FilterLogins(typeof(Customer));
            Customer result = null;

            string[] menuList = new string[customers.Count];
            for (int i = 0; i < customers.Count; i++)
                menuList[i] = customers[i].ToString();

            uint which = MenuSubsystem.DoCancellableSubSelect("Please select from the following customers:", menuList, "Selection: ");
            if (which > 0)
                result = customers[(int)which - 1] as Customer;

            return result;
        }

        private static Mortgage GetMortgageSelection(Customer customer)
        {
            List<Mortgage> accounts = new List<Mortgage>();

            foreach (Account acc in customer.Accounts)
            {
                if (acc is Mortgage)
                    accounts.Add(acc as Mortgage);
            }

            Mortgage result = null;

            string[] menuList = new string[accounts.Count];
            for (int i = 0; i < accounts.Count; i++)
                menuList[i] = accounts[i].ToString();

            uint which = MenuSubsystem.DoCancellableSubSelect("Please select from the following mortgages:", menuList, "Selection: ");
            if (which > 0)
                result = accounts[(int)which - 1] as Mortgage;

            return result;
        }

        public void SetMortgageLimit()
        {
            Customer cust;
            if ((cust = GetCustomerSelection()) != null)
            {
                Mortgage mort;
                if ((mort = GetMortgageSelection(cust)) != null)
                {
                    Console.Write("Specify limit: ");
                    decimal amount = decimal.Parse(Console.ReadLine());
                    mort.SetLimit(amount);
                }
            }
        }

        public override string ToString()
        {
            return string.Format("Manager {0}", base.ToString());
        }

        #region IMenus Members

        public override string MenuName
        {
            get { return "Manager Menu"; }
        }

        public override MenuOption[] MenuOpts
        {
            get
            {
                return new MenuOption[] {
                    new MenuCustomOption("Create a new teller", CreateTeller),
                    new MenuCustomOption("List all accounts", ListAllAccounts),
                    new MenuCustomOption("List all customers", ListAllCustomers),
                    new MenuCustomOption("List all tellers", ListAllTellers),
                    new MenuCustomOption("Specify a mortgage limit", SetMortgageLimit),
                    new MenuCustomOption("Change your password", base.ChangePassword),
                    new MenuSpecialOption("Logout", MenuSpecialOption.OptionType.Logout, true),
                    new MenuSpecialOption("Exit", MenuSpecialOption.OptionType.Exit, true) 
                };
            }
        }

        #endregion
    }
}

MenuCustomOption.cs

using System;

namespace Project_2
{
    public class MenuCustomOption : MenuOption
    {
        private MenuOption.MenuHandler _Handler;
        public MenuOption.MenuHandler Handler
        {
            get { return _Handler; }
        }

        public MenuCustomOption(string description, MenuHandler handler)
            : base(description)
        {
            _Handler = handler;
        }
    }
}

MenuOption.cs

using System;

namespace Project_2
{
    public abstract class MenuOption
    {
        public delegate void MenuHandler();

        private string _Description;
        public string Description
        {
            get { return _Description; }
        }

        public MenuOption(string description)
        {
            _Description = description;
        }
    }
}

MenuSpecialOption.cs

using System;

namespace Project_2
{
    public class MenuSpecialOption : MenuOption
    {
        public enum OptionType { None, Logout, Exit }

        private OptionType _Type;
        public OptionType Type
        {
            get { return _Type; }
        }

        private bool _ExitMenu;
        public bool ExitMenu
        {
            get { return _ExitMenu; }
            set { _ExitMenu = value; }
        }

        public MenuSpecialOption(string description, OptionType optionType, bool exitMenu)
            : base(description)
        {
            _Type = optionType;
            _ExitMenu = exitMenu;
        }
    }
}

MenuSubsystem.cs

using System;

namespace Project_2
{
    public static class MenuSubsystem
    {
        private static void DisplayMenu(string name, MenuOption[] options)
        {
            Console.WriteLine("n{0}", name);
            Console.WriteLine("{0}n", new string('=', name.Length));

            for (int i = 0; i < options.Length; i++)
            {
                Console.WriteLine("{0}. {1}", i + 1, options[i].Description);
            }
        }

        public static MenuSpecialOption.OptionType DoMenu(IMenus menuElement)
        {
            string name = menuElement.MenuName;
            MenuOption[] opts = menuElement.MenuOpts;
            bool terminate = false;
            uint selection;
            MenuSpecialOption.OptionType msotype = MenuSpecialOption.OptionType.None;

            do
            {
                DisplayMenu(name, opts);
                Console.Write("nEnter selection: ");
                if (uint.TryParse(Console.ReadLine(), out selection) == false || selection < 1 || selection > opts.Length)
                    Console.Error.WriteLine("Invalid selection.");
                else
                {
                    Console.WriteLine();
                    MenuOption o = opts[selection - 1];
                    if (o is MenuSpecialOption)
                    {
                        msotype = (o as MenuSpecialOption).Type;
                        if ((o as MenuSpecialOption).ExitMenu == true)
                            terminate = true;
                    }
                    else if (o is MenuCustomOption)
                    {
                        (o as MenuCustomOption).Handler();
                    }
                }
            } while (terminate == false);

            return msotype;
        }

        public static uint DoCancellableSubSelect(string intro, string[] options, string prompt)
        {
            uint selection = 0;
            bool result = false;

            do
            {
                Console.WriteLine("{0}", intro);
                for (int i = 0; i < options.Length; i++)
                {
                    Console.WriteLine("    {0}. {1}", i + 1, options[i]);
                }
                Console.WriteLine("    0. Cancel");
                Console.Write(prompt);
                if ((result = uint.TryParse(Console.ReadLine(), out selection)) == false || selection > options.Length)
                    Console.Error.WriteLine("nInvalid selection.n");
            } while (result == false || selection > options.Length);

            return selection;
        }
    }
}

Mortgage.cs

using System;

namespace Project_2
{
    public class Mortgage : Loan
    {
        private bool _InitialPurchase = false;

        public override bool Purchase(decimal value)
        {
            bool result = false;

            if (_InitialPurchase == false && value <= base.Limit)
            {
                _InitialPurchase = true;
                base.Limit = value;
                base.IncreaseBalance(value);
                result = true;
            }

            return result;
        }

        public Mortgage(Teller teller, uint number)
            : base(teller, number, 0.0M)
        {
        }

        public void PurchaseHandler()
        {
            Console.Write("Please enter the purchase value: ");
            decimal value = decimal.Parse(Console.ReadLine());
            if (Purchase(value) == false)
                Console.WriteLine("Purchase could not be processed.");
        }

        public void PaymentHandler()
        {
            Console.Write("Please enter the payment value: ");
            decimal value = decimal.Parse(Console.ReadLine());
            base.Payment(value);
        }

        public void SetLimit(decimal value)
        {
            if (base.Limit != 0)
                throw new MortgageLimitSpecifiedException();
            base.Limit = value;
        }

        public override string ToString()
        {
            return string.Format("Mortgage {0}", base.ToString());
        }

        #region IMenus Members

        public override string MenuName
        {
            get { return "Mortgage Menu"; }
        }

        public override MenuOption[] MenuOpts
        {
            get
            {
                return new MenuOption[] {
                    new MenuCustomOption("Purchase", PurchaseHandler),
                    new MenuCustomOption("Payment", PaymentHandler),
                    new MenuSpecialOption("Exit", MenuSpecialOption.OptionType.Exit, true)
                };
            }
        }

        #endregion
    }
}

 

MortgageLimitSpecifiedException.cs

using System;

namespace Project_2
{
    class MortgageLimitSpecifiedException : BMSException
    {
        private const string DEFAULT_MESSAGE = "Mortgage limit already specified";

        public MortgageLimitSpecifiedException()
            : base(DEFAULT_MESSAGE)
        {
        }

        public MortgageLimitSpecifiedException(string message)
            : base(message)
        {
        }

        public MortgageLimitSpecifiedException(string message, Exception innerException)
            : base(message, innerException)
        {
        }
    }
}

NoSuchUserException.cs

using System;

namespace Project_2
{
    class NoSuchUserException : BMSException
    {
        private const string DEFAULT_MESSAGE = "No such user registered";

        public NoSuchUserException()
            : base(DEFAULT_MESSAGE)
        {
        }

        public NoSuchUserException(string message)
            : base(message)
        {
        }

        public NoSuchUserException(string message, Exception innerException)
            : base(message, innerException)
        {
        }
    }
}

Program.cs

using System;

namespace Project_2
{
    class Program
    {
        private static User _User = null;

        private static void InitialiseUsers()
        {
            UserManager.Add(new Administrator("Administrator", "Administrator", "administrator", "administrator"));
            UserManager.Add(new Manager("Manager", "Manager", "manager", "manager"));
            UserManager.Add(new Teller("Teller", "Teller", "teller", "teller"));
            UserManager.Add(new Customer("Customer", "Customer", "customer", "customer"));
        }

        private static void DoLogin()
        {
            string login, password;
            User tmpUser;

            while(_User == null)
            {
                login = "";
                while(login == "")
                {
                    Console.Write("login: ");
                    login = Console.ReadLine();
                }
                Console.Write("password: ");
                password = Console.ReadLine();

                if ((tmpUser = UserManager.Find(login)) != null && tmpUser.Password == password)
                    _User = tmpUser;
                else
                    Console.Error.WriteLine("Invalid login");   
            }
        }

        public static void Main(string[] args)
        {
            InitialiseUsers();

            Console.WriteLine("*******************************************");
            Console.WriteLine("** Welcome to the Bank Management System **");
            Console.WriteLine("*******************************************n");
            Console.WriteLine("Login with username and password of 'administrator', 'manager', 'teller', or 'customer' to beginn");

            MenuSpecialOption.OptionType specFlag;
            do
            {
                DoLogin();
                specFlag = MenuSubsystem.DoMenu(_User);
                if (specFlag == MenuSpecialOption.OptionType.Logout)
                {
                    Console.WriteLine("Logged out.n");
                    _User = null;
                }
            } while (specFlag != MenuSpecialOption.OptionType.Exit);

            Console.WriteLine("****************************************************");
            Console.WriteLine("** Thank you for using the Bank Management System **");
            Console.WriteLine("****************************************************");
        }
    }
}

Teller.cs

using System;
using System.Collections.Generic;

namespace Project_2
{
    public class Teller : User
    {
        public Teller(string givenNames, string familyName, string login, string password)
            : base(givenNames, familyName, login, password)
        {
        }

        public void CreateCustomer()
        {
            string familyName;
            string givenNames;
            string login;
            string password;

            Console.Write("Enter family name: ");
            familyName = Console.ReadLine();

            Console.Write("Enter given names: ");
            givenNames = Console.ReadLine();

            Console.Write("Enter login name: ");
            login = Console.ReadLine();

            Console.Write("Enter password: ");
            password = Console.ReadLine();

            try
            {
                UserManager.Add(new Customer(givenNames, familyName, login, password));
            }
            catch (Exception e)
            {
                Console.Error.WriteLine("Error: {0}", e);
            }
        }

        private static Customer GetCustomerSelection()
        {
            List<User> customers = UserManager.FilterLogins(typeof(Customer));
            Customer result = null;

            string[] menuList = new string[customers.Count];
            for (int i = 0; i < customers.Count; i++)
                menuList[i] = customers[i].ToString();

            uint which = MenuSubsystem.DoCancellableSubSelect("Please select from the following customers:", menuList, "Selection: ");
            if (which > 0)
                result = customers[(int)which - 1] as Customer;

            return result;
        }

        private static CreditCard GetCreditCardSelection(Customer customer)
        {
            List<CreditCard> accounts = new List<CreditCard>();

            foreach (Account acc in customer.Accounts)
            {
                if (acc is CreditCard)
                    accounts.Add(acc as CreditCard);
            }

            CreditCard result = null;

            string[] menuList = new string[accounts.Count];
            for (int i = 0; i < accounts.Count; i++)
                menuList[i] = accounts[i].ToString();

            uint which = MenuSubsystem.DoCancellableSubSelect("Please select from the following credit cards:", menuList, "Selection: ");
            if (which > 0)
                result = accounts[(int)which - 1] as CreditCard;

            return result;
        }
        //Opening Balance 
    private decimal _OpenBalance=100;
        public decimal OpenBalance
        {
            get { return _OpenBalance; }
             set { _OpenBalance = value; }
        }

        public void CreateCashAccount()
        {
            Customer cust;
            if ((cust = GetCustomerSelection()) != null)
                AccountManager.OpenCashAccount(this, cust);
        }

//Teller to be able to list all accounts for a customer:

    public void ListAccountCustomer()
        {

            List<Customer> cust = new List<Customer>();
            if ((cust = GetCustomerSelection()) != null)

                Console.WriteLine(cust);
                Console.WriteLine(cust.ListAccounts());
                Console.WriteLine(cust.SelectAccount());
        }

        public void CreateCreditCardAccount()
        {
            Customer cust;
            if ((cust = GetCustomerSelection()) != null)
            {
                Console.Write("Enter limit: ");
                decimal limit;
                while (decimal.TryParse(Console.ReadLine(), out limit) != true)
                    Console.Error.WriteLine("Invalid input.");

                AccountManager.OpenCreditCardAccount(this, cust, limit);
            }
        }

        public void CreateMortgageAccount()
        {
            Customer cust;
            if ((cust = GetCustomerSelection()) != null)
                AccountManager.OpenMortgageAccount(this, cust);
        }

        public void ChangeCreditCardLimit()
        {
            Customer cust;
            if ((cust = GetCustomerSelection()) != null)
            {
                CreditCard cc;
                if ((cc = GetCreditCardSelection(cust)) != null)
                {
                    Console.Write("Change to limit (-ve to decrease): ");
                    decimal amount = decimal.Parse(Console.ReadLine());
                    if (amount < 0)
                        cc.DecreaseLimit(-amount);
                    else
                        cc.IncreaseLimit(amount);
                }
            }
        }

        public override string ToString()
        {
            return string.Format("Teller {0}", base.ToString());
        }

        #region IMenus Members

        public override string MenuName
        {
            get { return "Teller Menu"; }
        }

        public override MenuOption[] MenuOpts
        {
            get
            {
                return new MenuOption[] {
                    new MenuCustomOption("Create a new customer", CreateCustomer),
                    new MenuCustomOption("Open a cash account", CreateCashAccount),
                    new MenuCustomOption("List all accounts for a customer", ListAccountCustomer),
                    new MenuCustomOption("Open a credit card account", CreateCreditCardAccount),
                    new MenuCustomOption("Change credit card limit", ChangeCreditCardLimit),
                    new MenuCustomOption("Open a mortgage account", CreateMortgageAccount),
                    new MenuCustomOption("Change your password", base.ChangePassword),
                    new MenuSpecialOption("Logout", MenuSpecialOption.OptionType.Logout, true),
                    new MenuSpecialOption("Exit", MenuSpecialOption.OptionType.Exit, true)

                };
            }
        }

        #endregion
    }
}

Transaction.cs

using System;

namespace Project_2
{
    public abstract class Transaction 
    {
        private string _Tname;

         public string Tname
            {
        get { return _Tname; }
        set { _Tname = ""; }
        }

         private string[] _Ttype={ "positive", "negative"}
         public string[] Ttype
         {
        get { return _Ttype; }
    }
    }
}

User.cs

using System;

namespace Project_2
{
    public abstract class User : IMenus
    {
        private string _Login;
        public string Login
        {
            get { return _Login; }
            set { _Login = value; }
        }

        private string _Password;
        public string Password
        {
            get { return _Password; }
            set { _Password = value; }
        }

        private string _FamilyName;
        public string FamilyName
        {
            get { return _FamilyName; }
            set { _FamilyName = value; }
        }

        private string _GivenNames;
        public string GivenNames
        {
            get { return _GivenNames; }
            set { _GivenNames = value; }
        }

        public User(string givenNames, string familyName, string login, string password)
        {
            _Login = login;
            _Password = password;
            _FamilyName = familyName;
            _GivenNames = givenNames;
        }

        public override string ToString()
        {
            return string.Format("{0}: {1}, {2}", _Login, _FamilyName, _GivenNames);
        }

        protected virtual void ChangePassword()
        {
            Console.Write("Please enter current password: ");
            string oldPass = Console.ReadLine();
            Console.Write("Please enter new password: ");
            string newPass = Console.ReadLine();

            if (UserManager.ChangePassword(_Login, oldPass, newPass) == false)
                Console.WriteLine("Password change failed.");
            else
                Console.WriteLine("Password change succeeded.");
        }

        #region IBankMenu Members

        public virtual string MenuName
        {
            get { return "User Menu"; }
        }

        public virtual MenuOption[] MenuOpts
        {
            get
            {
                return new MenuOption[] {
                    new MenuSpecialOption("Logout", MenuSpecialOption.OptionType.Logout, true),
                    new MenuSpecialOption("Exit", MenuSpecialOption.OptionType.Exit, true) 
                };
            }
        }

        #endregion
    }
}

UserExistsException.cs

using System;

namespace Project_2
{
    class UserExistsException : BMSException
    {
        private const string DEFAULT_MESSAGE = "User already exists";

        public UserExistsException()
            : base(DEFAULT_MESSAGE)
        {
        }

        public UserExistsException(string message)
            : base(message)
        {
        }

        public UserExistsException(string message, Exception innerException)
            : base(message, innerException)
        {
        }
    }
}

UserManager.cs

using System;
using System.Collections.Generic;
using System.Linq;

namespace Project_2
{
    public static class UserManager
    {
        private static Dictionary<string, User> _RegisteredUsers = new Dictionary<string,User>();

        public static void Add(User newUser)
        {
            if(_RegisteredUsers.ContainsKey(newUser.Login))
                throw new UserExistsException();

            _RegisteredUsers.Add(newUser.Login, newUser);
        }

        public static User Find(string login)
        {
            if (_RegisteredUsers.ContainsKey(login))
                return (User)_RegisteredUsers[login];
            else
                return null;
        }

        private static void ConfirmLoginValid(string login)
        {
            if (_RegisteredUsers.ContainsKey(login) == false)
                throw new InvalidLoginException();
        }

        public static User Delete(string login)
        {
            ConfirmLoginValid(login);
            User result = _RegisteredUsers[login];
            _RegisteredUsers.Remove(login);
            return result;
        }

        public static bool ChangePassword(string login, string oldPassword, string newPassword)
        {
            bool result = false;

            ConfirmLoginValid(login);
            User u = _RegisteredUsers[login];
            if (u.Password == oldPassword)
            {
                u.Password = newPassword;
                result = true;
            }

            return result;
        }

        public static Dictionary<string, User>.KeyCollection UserList
        { 
            get { return _RegisteredUsers.Keys; } 
        }

        public static List<User> FilterLogins(Type userType)
        {
            return new List<User>(from user in _RegisteredUsers.Values where userType.IsInstanceOfType(user) select user);
        }
    }
}

C# is distributed together with a special environment on which it is executed, called the Common Language Runtime. This environment is part of the.NET Framework platform, which includes CLR, a package of standard libraries providing basic functionality, debuggers, compilers and other development tools. CLR programs are portable, when you can write them once then they can function with no changes or little changes on various hardware platforms and operating systems.

Students take C sharp programming assignment help to solve their assignments. They may upload their assignments or may send it through email. Our experts are highly qualified and experienced for years and are available 24 x 7.