Skip to content

oaknorthbank/csharp-interview

Repository files navigation

Credit Score Calculator - C# Implementation

Requirements

  • .NET 8.0 or higher
  • .NET CLI

Running the project

  • Build the project: dotnet build
  • Run the tests: dotnet test
  • Clean and run the tests: dotnet clean && dotnet test

Context

This project contains a first version of a simplified function that calculates a credit score given a credit report.

Credit score: A credit score is a prediction of a person's credit behavior, such as how likely you are to pay a loan back on time, based on information from your credit reports. For example, your credit score can go up and down based on how you pay your bills, how much debt you have, how long you've had credit accounts, and how often you apply for new credit.

Experian is a credit reporting company that defines the following ranges for credit scores in the UK:

  • "very poor" if the score is less or equals 560.
  • "poor" if the score is between 561 and 720.
  • "fair" if the score is between 721 and 880.
  • "good" if the score is between 881 and 960.
  • "excellent" if the score is between 961 and 999.

Credit report: consists of a person's credit utilisation percentage and payment history.

  • Credit utilisation percentage: Credit utilisation percentage shows how much of your available credit you're using. It refers to the ratio of your credit card balance to your credit limit.
  • Payment history: is a list of invoices that the person needs to pay.

Project Structure

csharp-interview/
├── src/
│   └── CreditScoreCalculator/
│       ├── CreditScoreCalculator.csproj
│       ├── CreditScoreCalculator.cs
│       ├── CreditScore.cs
│       ├── CreditReport.cs
│       ├── Invoice.cs
│       └── CreditScoreCategory.cs
├── test/
│   └── CreditScoreCalculator.Tests/
│       ├── CreditScoreCalculator.Tests.csproj
│       └── CreditScoreCalculatorTests.cs
└── README.md

Before the interview

  • Make sure you can run the project locally (dotnet test should run the tests).
  • Get familiar with the existing code.
  • Imagine this code was written a long time ago by an intern.
  • Don't write any code.

During the interview, we'll ask you to expand the current implementation of the credit score function and update tests accordingly. You'll have around 45 minutes for this.

This is how we work...

  • We like leaving the codebase better than we found it
  • We do TDD (test driven development)
  • We don't test implementation details but we do test user behaviour

Usage

using CreditScoreCalculator;

// Create a credit report with invoices and utilization percentage
var creditReport = new CreditReport(
    paymentHistory: new List<Invoice>(),
    creditUtilisationPercentage: 0.25f  // Now accepts float parameter
);

// Calculate credit score
var calculator = new CreditScoreCalculator();
calculator.GetCreditScore(creditReport);
var result = calculator.Result;

Console.WriteLine($"Score: {result.Value}");
Console.WriteLine($"Category: {result.Category}");
// Output: Score: 999, Category: EXCELLENT

Task

To be given during the interview.

About

Our pairing interview in C#

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages