Welcome to the CSharpPractice repository! This repository contains a structured collection of exercises and practice programs for mastering C# and .NET development, mapped chapter-by-chapter from foundational concepts to advanced concurrent programming.
- .NET 9.0 SDK
- An IDE such as Visual Studio 2022 or VS Code
To open and work with these exercises, open the main solution file CSharpPractice.sln in your preferred IDE, or use the .NET CLI:
# Clone the repository
git clone https://github.com/HappyMagabane/CSharpPractice.git
# Navigate into the folder
cd CSharpPractice
# Restore dependencies
dotnet restore
# Run a specific project (replace with project folder name)
dotnet run --project BasicVariables/BasicVariables.csprojBelow is the structured list of all practice topics and their corresponding projects in this repository:
- AdditionalWhileLoop - General: Practice: AdditionalWhileLoop
- AgeCalculator - General: Practice: AgeCalculator
- BMICalculator - General: Practice: BMICalculator
- BasicVariables - Variable Declaration, Initialization, Assignment and Display: Write a program (BasicVariables) that declares and initializes variables of appropriate data types and specified values.
- BooleanVote - Constants: Write a program (BooleanVote) that prompts the user to enter their age as an integer. Use a Boolean variable canVote to check if the user is eligible to vote (age >= 18). Display a message indicating whether the user can vote or not. NB: Use IF else statement
- ConstantVariables - Constants: Write a program (ConstantVariables) that define constants for common mathematical values such as PI (π) = 3.1415926536 and the speed of light (C) = 299 792 458 m/s.
- ContinueStatementSequence - General: Practice: ContinueStatementSequence
- ContinueStatementSum - General: Practice: ContinueStatementSum
- DoWhileLoopAverageCalculator - General: Practice: DoWhileLoopAverageCalculator
- DoWhileLoopGuessNumber - General: Practice: DoWhileLoopGuessNumber
- DoWhileLoopRollDice - General: Practice: DoWhileLoopRollDice
- GradeCalculator - General: Practice: GradeCalculator
- LoopsFactorial - General: Practice: LoopsFactorial
- MenuSelection - General: Practice: MenuSelection
- MultiplicationNestedForLoop - General: Practice: MultiplicationNestedForLoop
- NullCoalescingOperator - General: Practice: NullCoalescingOperator
- NumericForLoops - General: Practice: NumericForLoops
- NumericWhileLoop - General: Practice: NumericWhileLoop
- PasswordStrengthChecker - General: Practice: PasswordStrengthChecker
- SimpleBankingSystem - General: Practice: SimpleBankingSystem
- SimpleEncryptionProgram - General: Practice: SimpleEncryptionProgram
- StringConcatenationOperators - General: Practice: StringConcatenationOperators
- StringReversalProgram - General: Practice: StringReversalProgram
- TemperatureConverter - General: Practice: TemperatureConverter
- TextAnalysisTool - General: Practice: TextAnalysisTool
- TicketPriceCalculator - General: Practice: TicketPriceCalculator
- WhileLoopPassword - General: Practice: WhileLoopPassword
- dataTypesCasting - Data Types and Casting: Write a program (TypeAndCastCalculator) that performs arithmetic operations (addition +, division /) on two numeric (number1, number2) variables of type integer which entered by prompting user. Store the result of addition into sum variable and store the result of division into quotient variable.
- AssignmentCounter - Arithmetic Operators: Implement a AssignmentCounter program using the += operator to increment the counter on variable counter with each iteration. Before each increment, print the counter as shown above. NB: Using While Statement.
- CompareNumber - Comparison Operators: Write a program CompareNumber that compares two numbers (number1 and number2) entered by the user and displays whether the first number is greater, less than, or equal to the second number. Using If else statement
- ComparePassword - Comparison Operators: Implement a program ComparePassword that checks if a user-entered password userPassword matches a predefined constant PASSWORD initialized with myPass@2023 using the equality (=) operator. NB: Using If statement
- LogicInRange - Logical Operators: Write a program LogicInRange that checks if a number entered by the user is within a specified range (e.g., between 1 and 100) using logical operators (And, Or, Not). NB: Using If statement
- LogicPass - Logical Operators: Implement a program LogicPass that checks if a student's mark is passing (greater than or equal to 60) and whether their attendance is satisfactory (at least 80% attendance) using logical operators. NB: Using If statement
- SimpleCalculator - Arithmetic Operators: Write a program (SimpleCalculator) that performs arithmetic operations (addition, subtraction, multiplication, division, modulus, exponent) on two numeric variables which entered by prompting user.
- TernaryMaximum - Logical Operators: Implement a program LogicPass that checks if a student's mark is passing (greater than or equal to 60) and whether their attendance is satisfactory (at least 80% attendance) using logical operators. NB: Using If statement
- AccessStringCharacters - Accessing Strings: Write a AccessStringCharacters program that asks the user to enter a word. Display the first and last letter of the word.
- CharacterMethods - Accessing Strings: Write a program CharacterMethods which enters a single character and determine if it’s the letter, digit, white space, uppercase, lowercase, both letter and number.
- FirstLettersDisplay - Typical Programs: Name Initials: Write a program that asks the user to enter a name (which contact first and middle). Display their initials based on the name entered.
- StringMethods - General Exercises: Write a program called StringMethods that perform the following using their respective above-mentioned methods:
- IfAdultProgram - General Exercises: Write a program IfAdult that asks the user to enter their age. If the age is greater than or equal to 18, display a message indicating they are an adult; otherwise, display a message indicating they are a minor.
- IfCredentials - General Exercises: Create a program IfCredentials that asks the user to enter their username and password. If both are correct, display a welcome message; otherwise, display an error message.
- IfLeapYearProgram - General Exercises: Write a program IfLeapYear that checks if a user-entered year is a leap year. If it is, display a message indicating it's a leap year; otherwise, display a message indicating it's not. Use IsLeapYear() method.
- IfPositiveNumber - General Exercises: Implement a program ifPositiveNumber that checks if a user-entered number is positive, negative, or zero using If-Else statements.
- SelectionIfTriangle - Selection Control with Boolean Expressions: Write a SelectionIfTriangle program that asks the user to enter three numbers and checks if they form a valid triangle (the sum of any two sides is greater than the third side). Display the result using If-Else statements.
- SelectionWithdraw - Selection Control with Boolean Expressions: Create a SelectionWithdraw program that simulates a simple ATM. Ask the user to enter their account balance and check if it's greater than zero. If it is, allow them to withdraw money; otherwise, display an error message.
- SwitchDayOfTheWeek - Switch Statements: Implement a program SwitchDayOfTheWeek that asks the user to enter a day of the week (1 for Monday, 2 for Tuesday, etc.) and then displays the corresponding name of the day using a Switch statement.
- SwitchMonthProgram - Switch Statements: Write a program SwitchMonth that converts a user-entered month number (1 for January, 2 for February, etc.) into the corresponding month name using a Switch statement.