Angular

How to do the student mark calculation in Angular

In this tutorials will teach How to do the student mark calculation in Angular.

First you have to add the FormsModule inside the imports.

Create the new Components studentmarks

studentmarks.component.html

<form>

    <h1>Add Students Marks Calculation</h1>

<div>
  <label >Marks 1</label>
  <input type = "text"  name="num1" [(ngModel)] = "marks1" class="form-control"  placeholder="Enter Num 1">

</div>

  <div>
    <label >Marks 2</label>
    <input type = "text"  name="num2"  [(ngModel)] = "marks2" class="form-control"  placeholder="Enter Num 2">
  
  </div>

  <div>
    <label >Marks 3</label>
    <input type = "text"  name="num2"  [(ngModel)] = "marks3" class="form-control"  placeholder="Enter Num 2">
  
  </div>


  <div >
    <label >Total</label>
    <input  class="form-control"  placeholder="Total" value="{{ result }}"> 
  </div>

  <div >
    <label >Average</label>
    <input  class="form-control"  placeholder="Total" value="{{ avg }}"> 
  </div>

  <div *ngIf="avg > 50; else grade">
    Pass
  </div>

  <ng-template #grade>
    Fail
  </ng-template>

 
<button  (click)="StudentTot()" class="btn btn-primary mt-4">Submit</button>

</form>

studentmarks.component.ts
marks1:string = ”;
marks2:string = ”;
marks3:string = ”;
result:number=0;
avg:number=0.0;
StudentTot()
{
this.result = parseInt(this.marks1) + parseInt(this.marks2) + parseInt(this.marks3);
this.avg = (this.result) / 3 ;
}
import { Component, OnInit } from '@angular/core';

@Component({
  selector: 'app-studentmarks',
  templateUrl: './studentmarks.component.html',
  styleUrls: ['./studentmarks.component.scss']
})
export class StudentmarksComponent implements OnInit {

  marks1:string = '';
  marks2:string = '';
  marks3:string = '';
  result:number=0;
  avg:number=0.0;


StudentTot()
{
  this.result = parseInt(this.marks1) + parseInt(this.marks2) + parseInt(this.marks3);
  this.avg = (this.result) / 3 ;

}

  constructor() { }

  ngOnInit(): void {
  }


}

i have attached the video link below. which will do this tutorials step by step

 

admin

Recent Posts

Chat with Claude AI Free – Your Super-Smart AI Buddy

It's like having a super-smart buddy that is always there to help you write stories,…

2 days ago

Best Festivals UK 2025 [Free Guide Included]

The UK is known for its rich history, diverse culture, and most of all  its…

5 days ago

Bank Holidays 2025 UK – Plan Your Perfect Long Weekends

Do you have a plan for your next holiday? Being aware of the Bank Holidays within the…

5 days ago

Master Cursor AI Full Guide for Students & Creators

The world is rapidly changing of software development AI-assisted tools for coding have become the main focus. As…

6 days ago

Google Gemini AI Free AI Tool for Students & Creators

Google Gemini AI is among the top talked about developments. What exactly is it? What…

6 days ago

Top 5 Reasons You Should Use Grubby AI Humanizer in 2025

As the need for AI content undetectable humanization software skyrockets with more and more AI…

2 weeks ago