C# Projects

C# Projects

1. Simple Interest

Where: Formula – I = P × r × t

I is the simple interest.
P is the principal amount (the initial amount of money).
r is the annual interest rate (decimal).
t is the time the money is invested for, in years.


Example Usage

If the user enters:

Principal amount (P): 1000
Annual interest rate (r): 5%
Number of years (t): 3
The program will calculate and display:

The simple interest is: 150.00
The total amount after 3 years is: 1150.00

2. How to find the Biggest Number from the User Given array

Example Usage


If the user inputs:
• Number of elements: 5
• Element 1: 10
• Element 2: 25
• Element 3: 7
• Element 4: 30
• Element 5: 15
The program will output:
The elements of the array are:
10
25
7
30
15

The largest number in the array is: 30

3. Give an Example for the below operators.

1. assignment operator [ = ]
 
Like –> int a = 10 ;
 
2. arithmetic operator [ +, -, *, /, % ]
3. comparison operator [ == ]
4. conditional operators [ &&, || ]
5. Ternary operator  [ boolean ? true : false  ]
6. Null coalescing operator [ ?? ]
7. Relational Operator <, >

4. Give an Example for the below Math Class :

1. Min
 
Like –> int a = 10; int b = 20; 
int min = Math.Min(a, b); // min will be 10 
Console.WriteLine(“Min: ” + min);
 
2. Max
3. Sqrt
4. Abs
5. Floor
6. Round
7. Power 
8. Truncate

5. Give an Example for the Below array methods.

1. Length
 
Like -> int[] numbers = { 1, 2, 3, 4, 5 };
int length = numbers.Length; // length will be 5 
  Console.WriteLine(“Array Length: ” + length);
 
2. IndexOf
3. Sort
4. Copy
5. Foreach
6. Equals

6. Determine if the user-given number is prime (a number that can only be divided by 1 and itself ) like below.

7. Create a console application where users can manage their to-do list by using a collection of List.

8. Implement a Simple Calculator

  • Write a console application that takes two numbers and an operator (+, -, *, /) from the user and performs the corresponding operation.
  • Use switch statements to handle the different operations.
  • Ensure proper validation and error handling for invalid input or division by zero.

9. Implement a Simple Number Guessing Game

  • Write a console application that generates a random number between 1 and 100 by using the random method of math class
  • Use a while loop to allow the user to guess the number until they get it right.
  • Provide feedback to the user whether their guess is too high or too low.

10. Abstract Class and Inheritance

  • Create an abstract class Shape with an abstract method Area().
  • Implement derived classes Circle and Rectangle that calculate the area of the respective shapes.
  • Write a console application that creates instances of Circle and Rectangle, sets their dimensions, and displays their areas.
  • Formula for circle – Math.PI * Radius * Radius;
  • Formula for rectangle – Width * Height;

11. Compound Interest Calculation

Create a C# program to calculate the compound interest on a principal amount. The user should be able to input the principal amount, annual interest rate, number of times interest is compounded per year, and the number of years. Implement a method that calculates the compound interest and another method that displays the results.
Requirements:
1. Create a method to calculate compound interest using the formula:
where:
Formula

o A is the amount of money accumulated after n years, including interest.
o P is the principal amount (the initial sum of money).
o r is the annual interest rate (decimal).
o n is the number of times that interest is compounded per year.
o t is the number of years the money is invested for.

2. Create a method to display the results.

3. Allow the user to input values for P, r, n, and t and use the methods to calculate and display the compound interest.
Example Usage
When you run the program, it will prompt you to enter the following:
• Principal amount (P)
• Annual interest rate (r) (as a decimal, e.g., 0.05 for 5%)
• Number of times interest is compounded per year (n)
• Number of years the money is invested for (t)
For example:
• Principal amount (P): 1000
• Annual interest rate (r): 0.05
• Number of times interest is compounded per year (n): 4
• Number of years the money is invested for (t): 5

12. Bank Account Management System

Create a bank account management system using encapsulation and abstraction. The system should allow users to create accounts, deposit money, withdraw money, and check balances.

Requirements:

  1. Encapsulate the account balance.
  2. Abstract the operations into an interface.
  3. Implement the interface in a concrete class.

Like below