Posts

Showing posts from May, 2024

Angular: building basic calculator

Image
Introduction In this tutorial, we will walk through the steps to create a simple calculator application using Angular. This exercise is designed to help you practice your Angular skills and understand the basics of building a user interface and handling events. Prerequisites Before you begin, ensure you have the following: Basic understanding of Angular Angular CLI installed Node.js and npm installed Step 1: Setting Up the Project First, let's create a new Angular project. Open your terminal and run: ng new BasicCalculator  cd BasicCalculator  ng serve This will set up a new Angular project and start the development server. You can view the default application by navigating to http://localhost:4200 in your browser. Step 2: Designing the Calculator UI In app.component.html, design the UI of the calculator. Here's a simple structure to get you started: <div class="container"> <div class="calculator"> <div><input class=...

Beginner: Temperature Converter in C#

Image
Introduction In this tutorial, we will create a simple console application in C# that converts temperatures between Celsius, Fahrenheit, and Kelvin. This is a great project for beginners to practice basic programming concepts and console input/output operations. Code Implementation: ITemperatureConverter internal interface ITemperatureConverter { TemperatureUnit ReadConvertUnit(string baseUnit); bool IsInputValid(string baseValue, TemperatureUnit baseUnit, TemperatureUnit targetUnit); decimal Process(string baseUnitValue, TemperatureUnit baseUnitEnum, TemperatureUnit targetUnitEnum); } TemperatureDataService Read user input public TemperatureUnit ReadConvertUnit(string inputUnit) { if (!int.TryParse(inputUnit, out var unit)) { Console.WriteLine("Invalid temperature unit. Please enter convert unit: "); inputUnit = Console.ReadLine(); ReadConvertUnit(inputUnit); ...

Building an Angular App: To-Do list

Image
Introduction In this post, I'll share my experience building a small Angular application called "To-Do List". This is a practice project to delve deeper into Angular concepts. Application Overview Simple angular application Basic Angular concepts No API calls Pure front-end implementation Code Snippet app.component.html <div class="container-fluid"> <div class="container"> <div class="row align-items-center"> <div class="col-4"> <div class="card"> <div class="card-header"> <label for="exampleFormControlInput1" class="form-label">Add to-do</label> </div> <div class="card-body"> <h5 class="card-title">New Do It</h5> <input type="text" class="form-control" [(ngModel)]="toDoValue" i...

Palindrome Checker

Image
C# Exercise: Palindrome Checker C# Exercise: Palindrome Checker Description Write a C# program that checks if a given string is a palindrome. A palindrome is a word, phrase, number, or other sequence of characters that reads the same forward and backward, ignoring spaces, punctuation, and capitalization. For example, "radar" and "A man a plan a canal Panama" are palindromes. Program.cs Console.WriteLine("Enter a text to check if it is a palindrome"); var text = Console.ReadLine(); var check = new PalindromeChecker.Class.PalindromeChecker(); if (string.IsNullOrEmpty(text)) Console.WriteLine("Text value empty"); if (check.IsPalindrome(text)) Console.WriteLine($"'{text}' is a palindrome"); else Console.Writ...
Image
C# Exercise: Fibonacci Sequence C# Exercise: Fibonacci Sequence Description Write a C# program to generate the Fibonacci sequence up to a specified number of terms. The Fibonacci sequence is a series of numbers where each number is the sum of the two preceding ones, usually starting with 0 and 1. For example, the first few numbers in the Fibonacci sequence are 0, 1, 1, 2, 3, 5, 8, 13, 21, ... Your program should prompt the user to enter the number of terms they want in the Fibonacci sequence and then output the sequence up to that number of terms. Exercise Console.WriteLine("Enter the number of terms for the Fibonacci sequence:"); var numTerms = Convert.ToInt32(Console.ReadLine()); var iteration = 0; var firtNumber = 0; var secondNumber = 1; var nextNumber = 0; ...