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

Apache Kafka

Blog banner

Travel Geek ‘The last $50k in Switzerland’

Blog banner

Virtual Memory

Blog banner

Cloud Security: Trends and Innovations

Blog banner

Multiprocessor and Multicore Organization

Blog banner

MODERN OPERATING SYSTEMS

Blog banner

Excel records

Blog banner

12 Principles of Animation

Blog banner

Deadlock and Starvation in an Operating System

Blog banner

From Procrastinator to Performer: How to Beat the Last-Minute Rush

Blog banner

Evolution of Operating System

Blog banner

Cryptanalysis tool

Blog banner

Cache Memory(142)

Blog banner

SECURITY RISKS OF REMOTE WORKING

Blog banner

Real Time Scheduling

Blog banner

AutoML: The Future of Automated Data Science

Blog banner

Threat from Inside: Educating the Employees Against Cyber Threats

Blog banner

GIS in Mapping and landslide alert in Bangladesh

Blog banner

Esri India launches Policy Maps.

Blog banner

Types of email

Blog banner

Deadlock in Operating System

Blog banner

Satellite Based Positioning

Blog banner

Rules and Regulations of Networking: "Standards and Protocols" - Part 1

Blog banner

LIFEHACKER

Blog banner

Processes : Process description and control

Blog banner

Ethical Issues in Data Science and Role of Data Science in Smart Cities

Blog banner

Open Source Project By Google

Blog banner

Linux

Blog banner

What is 'Multi-core and Multi-threading' ?

Blog banner

Big Data Architecture

Blog banner

10 Alien Encounters and Abduction Stories

Blog banner

Different types of scam frauds

Blog banner

Health and fitness in technology

Blog banner

Key to success in Sports

Blog banner

Deadlock

Blog banner

Benefits of yoga and meditation

Blog banner

LiquidPlanner

Blog banner

SNAPCHAT

Blog banner

Ethical Hacking

Blog banner

Affiliate Marketing V/S Influencer Marketing

Blog banner

Data Warehousing

Blog banner

OS PROCESS DESCRIPTION AND CONTROL-SARVAGYA JALAN

Blog banner