wisemonkeys logo
FeedNotificationProfileManage Forms
FeedNotificationSearchSign in
wisemonkeys logo

Blogs

Student Grade Calculator in LISP

profile
Zaobiya Khan
Jul 16, 2025
2 Likes
1 Discussions
0 Reads

The program performs the following key functions:


  1. Takes user input for the three scores, each between 0 and 100.
  2. Validates that the entered scores are numbers within the correct range.
  3. Calculates the average of the three scores.
  4. Determines the letter grade (A–F) based on the calculated average:


A: 90–100

B: 80–89

C: 70–79

D: 60–69

F: below 60


Displays the results: individual scores, average score (formatted to 2 decimal places), and final letter grade.


Program:-


;; Student Grade Calculator

(defun calculate-grade (total)

(cond ((>= total 90) "A")

((>= total 80) "B")

((>= total 70) "C")

((>= total 60) "D")

(t "F")))


(defun get-valid-score (prompt min max)

(format t "~%~A (Enter score between ~D and ~D): " prompt min max)

(let ((score (read)))

(if (and (numberp score) (>= score min) (<= score max))

score

(progn

(format t "Invalid score! Please enter a number between ~D and ~D~%" min max)

(get-valid-score prompt min max)))))


(defun main ()

(format t "~%Welcome to Student Grade Calculator~%")

;; Get scores for different components

(let* ((assignment (get-valid-score "Enter Assignment score" 0 100))

(midterm (get-valid-score "Enter Midterm score" 0 100))

(final (get-valid-score "Enter Final exam score" 0 100))

;; Calculate weighted total

(total (/ (+ assignment midterm final) 3))

(final-grade (calculate-grade total)))

;; Display results

(format t "~%Results:~%")

(format t "Assignment Score: ~D~%" assignment)

(format t "Midterm Score: ~D~%" midterm)

(format t "Final Score: ~D~%" final)

(format t "Average Score: ~,2F~%" total)

(format t "Final Grade: ~A~%" final-grade)))


;; Run the program

(main)


Output:


Comments ()


Sign in

Read Next

Binary Search Tree (BST) in Data Structure

Blog banner

The Right way of cooking

Blog banner

Cloud Technology and its Implications for Entrepreneurship

Blog banner

Objectives and functions of Operating System...

Blog banner

File Management In OS

Blog banner

'Positivity in life'

Blog banner

INTRANET

Blog banner

The Role of Teachers in Building a Child’s Confidence

Blog banner

Memory Management in Operating System

Blog banner

Fun Christmas Activities For Toddlers & Kids

Blog banner

Spyware

Blog banner

Cloud Security: Trends and Innovations

Blog banner

How China Regained It's World's Largest Growing Economy Status

Blog banner

ACHIEVEMENTS IN OPERATING SYSTEMS

Blog banner

Gamer life

Blog banner

LIMITED EDITION

Blog banner

WAKE UP ITS FOOD o'CLOCK...!!!!!

Blog banner

Skills An Ethical Hacker Must Have

Blog banner

Brain wash of social media

Blog banner

College Life

Blog banner

ASANA- A Management System.

Blog banner

LinkedIn: Watch out for these 7 upcoming updates in 2023

Blog banner

10 Interesting Facts about Attack on Titan

Blog banner

Processing Crime and Incident Scenes

Blog banner

JIRA SOFTWARE

Blog banner

Big Data Architecture

Blog banner

Health and fitness

Blog banner

Article on IT development trends

Blog banner

File management -disha parekh

Blog banner

Swiggi

Blog banner

How to make Pancakes

Blog banner

Fitness

Blog banner

Mumbai Metro 3

Blog banner

Understanding Business Layer in Data Science

Blog banner

Types of OS

Blog banner

Man In The Middle Attack

Blog banner

Who decides your overthinking, anyway?

Blog banner

“CONSISTENCY” in Social Media Marketing

Blog banner

Affiliate Marketing V/S Influencer Marketing

Blog banner

Kernel Modes: User Mode vs. Kernel Mode - 80

Blog banner

Kafka - A Framework

Blog banner

Buffering

Blog banner