A Small Project to Force Real Method Design
This project is intentionally simple.
But it has one strict rule:
You are not allowed to write everything inside
Main.
You must separate logic into methods.
The goal is not math.
The goal is structure.
Why This Project Matters
Many beginners write programs like this:
- All input
- All logic
- All printing
… inside Main.
It works.
But it builds a terrible habit.
This project forces you to:
- Think in terms of responsibilities
- Separate input from processing
- Separate processing from output
- Use parameters and return values correctly
If you cannot structure this small calculator properly,
you cannot structure larger systems later.
System Flow
Your program must follow this exact flow.
1. Input
Ask the user for:
- Number 1
- Number 2
Use:
Console.ReadLine()int.Parse()
You are responsible for converting the string input into integers.
2. Select
Ask the user which operation they want to perform.
For example:
- Add
- Subtract
- Get Remainder
This selection must influence which method is called.
3. Process (This Is the Core)
Use an if statement to decide which method to call.
- If the user selects 1 → call
Add(num1, num2) - If the user selects 2 → call
Subtract(num1, num2) - If the user selects 3 → call
GetRemainder(num1, num2)
Each method must:
- Receive two integers as parameters
- Return an integer result
No printing inside the calculation methods.
They must return, not print.
4. Output
Take the value returned by the method
and print it in Main.
Processing and output must remain separate.
Required Concepts
You must use:
int.Parse- Methods with parameters
- Methods with return values
-
%(modulo operator for remainder)
If you skip any of these, you are skipping the point of the exercise.
Design Constraints
To make this meaningful:
- Do not duplicate calculation logic inside
Main. - Do not print inside your math methods.
- Do not hard-code numbers.
- Do not collapse everything into one method.
If it feels slightly uncomfortable, you are probably doing it right.
Why I Am Not Posting the Solution
Because the solution is not the goal.
The goal is:
- Thinking through structure
- Making mistakes
- Refactoring
- Understanding why separation matters
If you can build this cleanly,
you understand:
- Method design
- Return values
- Responsibility separation
- Basic program architecture
If you struggle, that is even better.
That struggle is the real exercise.
Top comments (0)