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

DNS Cache

Blog banner

A-B-C of Networking: Part-3 (Topology [Bus & Star])

Blog banner

URL vs Domain

Blog banner

Steps to create an Ubuntu EC2 Instance with GUI in AWS

Blog banner

Modern Operating system

Blog banner

KAHAWA TEA

Blog banner

The role of artificial intelligence in automating digital forensic analysis.

Blog banner

Denial-of-Service and Distributed Denial-of-Service Attack Techniques

Blog banner

SPAM

Blog banner

Scheduling in Operating Systems

Blog banner

GIS

Blog banner

Survey of Which Movies Types people are Prefer to Watch in India.

Blog banner

Europe Through My Lens

Blog banner

Memory Management of Operating System(OS)

Blog banner

From Loom to Luxury: How Patola Elevates Modern Wardrobes

Blog banner

Dove’s Real Beauty Campaign- Case Study

Blog banner

Mutual exclusion

Blog banner

What is Brute Force Attack? How to defend against it?

Blog banner

“Shot on iPhone” : A campaign by Apple that turned into a prodigy

Blog banner

Threat from Inside: Educating the Employees Against Cyber Threats

Blog banner

MailChimp

Blog banner

Uniprocessor scheduling

Blog banner

Key to success in Sports

Blog banner

Tiranga - Abbas Haveliwala

Blog banner

Social Engineering Attacks

Blog banner

MODERN OPERATING SYSTEMS

Blog banner

Friendship

Blog banner

Virtual memory in os

Blog banner

Expressing and Measuring Risk (Risk Management)

Blog banner

Defining youtubr

Blog banner

LiquidPlanner

Blog banner

10 Signs your Computer has Virus

Blog banner

Direct Memory Access

Blog banner

Health and fitness

Blog banner

LTE Technology

Blog banner

Modern operating system

Blog banner

Big Data Architecture

Blog banner

EFT

Blog banner

I/O Buffering

Blog banner

Digital Balance: Keeping Children Mindful in the Screen Age

Blog banner

Strengthening Active Directory Security

Blog banner

LIFEHACKER

Blog banner