Console Applications
Student Grade Calculator
Build a console application that calculates totals, averages, grades, and pass or fail results.
Beginner60 minutes5 features
What you will build
Create a small application that accepts student marks, validates the values, calculates the result, and displays a clearly formatted report.
Learning objectives
- Clean architecture and separation of concerns
- Object-Oriented Design (Classes, Structs, Enums)
- Dependency Injection for testability
- Immutability and data safety
- Precision math and rounding (e.g., BigDecimal/Decimal)
- Robust console input validation and error handling
- Using modern standard libraries (Streams/Algorithms)
Prerequisites
- Variables and Data Types
- Control flow (If/Else, Switch, Loops)
- Basic Object-Oriented Concepts (Classes or Structs)
- Understanding of Functions/Methods
- Basic terminal/console usage
Core requirements
- Read student details: Accept the student name and five subject marks.
- Validate marks: Allow marks only from 0 to 100.
- Calculate result: Calculate total and average accurately.
- Assign grade: Assign a grade from the calculated average.
- Display report: Print a readable final result.
Project milestones
- Accept input
Read the student name and five marks.
- Validate the marks
Reject any value outside the allowed range.
- Calculate total and average
Use suitable numeric types and avoid unintended integer division.
- Assign the grade
Apply the project grade boundaries with conditional logic.
- Display and test the report
Format the report and test normal and boundary values.
Sample interaction
Student Grade Calculator
Enter marks from 0 to 100 for five subjects.
Student name: Saad
English mark: 98
Mathematics mark: 98
Science mark: 87
Computer mark: 88
Social Studies mark: 85
--------------------------------------------------
STUDENT GRADE REPORT
--------------------------------------------------
Student: Saad
Subject Mark
--------------------------------------------------
English 98
Mathematics 98
Science 87
Computer 88
Social Studies 85
--------------------------------------------------
Total 456 / 500
Average 91.20
Grade A+
Result Pass
--------------------------------------------------Testing checklist
- Test all valid marks.
- Test 0 and 100.
- Test a failing mark.
- Test a value below 0.
- Test a value above 100.
Choose an implementation
Build with JavaStarter files and reference solutionBuild with CStarter files and reference solutionBuild with C++Starter files and reference solutionBuild with PythonStarter files and reference solutionBuild with C#Starter files and reference solutionBuild with JavaScriptStarter files and reference solution
Save your progress
Sign in to save completed milestones and continue this project later.
Sign in or registerDownload Reference Solution
Free solution — sign in to download
This project's reference solution is completely free. Sign in to get instant access.
Sign in to download free