wisemonkeys logo
FeedNotificationProfileManage Forms
FeedNotificationSearchSign in
wisemonkeys logo

Blogs

Student Grade Calculator in LISP

profile
Zaobiya Khan
Jul 16, 2025
2 Likes
1 Discussions
4 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

The Memory Hierarchy

Blog banner

Why Time Management Is the Secret to College Success (and How to Master It)

Blog banner

How GIS in Agriculture Eliminates Guesswork

Blog banner

Concurrency:Deadlock and Starvation

Blog banner

I/O Management and Disk Scheduling

Blog banner

Short-Form Video Marketing: Why It's Dominating the Internet

Blog banner

Atlantis - The Lost Island.........

Blog banner

Network Footprinting in Cybersecurity

Blog banner

Memory management

Blog banner

c

Blog banner

Mail merge

Blog banner

A True Friendship

Blog banner

What if COVID does not exist!

Blog banner

RSA (Rivest-Shamir-Adelman) Algorithm

Blog banner

File Allocation Methods

Blog banner

Hacking

Blog banner

What is online marketing and why do you need to know about it ?

Blog banner

Natural Language Processing(NLP)

Blog banner

KEAP MANAGEMENT SYSTEM

Blog banner

GEOLOGY AND GEO-TECTONIC FRAME WORK OF WESTERN BASTAR CRATON

Blog banner

The evolution of OS

Blog banner

Evolution of OS

Blog banner

Spyware

Blog banner

Embracing the power of Modern Machine UNIX

Blog banner

Networking 101: How to Build Meaningful Connections in College

Blog banner

Memory Management

Blog banner

Threads in OS

Blog banner

KASHMIR TRIPS

Blog banner

Method of Evaluating Information Security Level in an Organization

Blog banner

Dudhasagar waterfall ?

Blog banner

Global versus Indian Mental Health Differences

Blog banner

Scheduling

Blog banner

Title: Modern Operating Systems: Powering the Digital Era

Blog banner

Hash password! Is it really secured?

Blog banner

Why Travellers from Miami & Orlando Are Visiting Arcadia for Weekend Getaways?

Blog banner

What Your Child Learns During Free Play (That You Might Not Notice)

Blog banner

The Power of Pretend Play: What Role-Playing Teaches Preschoolers

Blog banner

INTERNET

Blog banner

The Bold Digital Marketing Moves That Made Durex India’s Second-Largest Condom Brand

Blog banner

TAILS OS

Blog banner

Monday. com App

Blog banner

Product Discount Calculator

Blog banner