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

How To Invest in Indian Stock Market For Beginners. ~ Tutorial 2 (NSDL And CSDL) Continued...

Blog banner

Importance Of Education.

Blog banner

BLOCKCHAIN MACHANISM

Blog banner

Human Error: The weakest link in Cybersecurity

Blog banner

How to Conquer Depression ?

Blog banner

Water Resources are about to exhaust...

Blog banner

Earth with no trees

Blog banner

Bit Coins

Blog banner

Artificial Intelligence and I

Blog banner

Exploring Human Factors in Cyber Forensics Investigations.

Blog banner

How to write a cover letter

Blog banner

OPERATING SYSTEM OBJECTIVES AND FAULT TOLERENCE.

Blog banner

Information of meesho company

Blog banner

Khau Galli – Vile Parle

Blog banner

FASHION

Blog banner

Trends that began during the pandemic

Blog banner

10 Reasons why Monica and Chandler are the best couple ever.!!!

Blog banner

"Can Lisp do Machine Learning?"

Blog banner

Article on Zoho Corporation

Blog banner

10 Alien Encounters and Abduction Stories

Blog banner

Memory Hierarchy

Blog banner

Big O Notation

Blog banner

THE ACTORS LIFE

Blog banner

Kernel Modes: User Mode vs. Kernel Mode - 80

Blog banner

(Input/Output) in os

Blog banner

In the world of Technology...

Blog banner

10 Survival Tips that might save your life

Blog banner

What is time ? The term which has astonished Scientists

Blog banner

BASICS OF SHARE MARKET

Blog banner

Deadlock

Blog banner

Service Catalogue Management

Blog banner

The Role of cryptography in cyber security

Blog banner

Reconnaissance

Blog banner

Embracing the power of Modern Machine UNIX

Blog banner

Quality check in IT services

Blog banner

WHAT IS TWITTER AND HOW DOES IT WORK

Blog banner

Why we fail after giving 100% ?

Blog banner

KAHAWA TEA

Blog banner

Process and Threading

Blog banner

Simple Ways to Grow Your Brand Online

Blog banner

Models of Information Security.

Blog banner

The Peephole

Blog banner