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

Direct Memory Access

Blog banner

Multicore and multithreading 171

Blog banner

OPERATING SYSTEM

Blog banner

Memory heirchy

Blog banner

FREE VERSION OF G-MAIL

Blog banner

Why is online marketing is important in current scenario

Blog banner

Process states

Blog banner

Processes : Process description and control

Blog banner

Knowledge Management in Continual Service improvement (CSI)

Blog banner

I/O Buffering

Blog banner

ZOHO

Blog banner

GIS Topography

Blog banner

INTERNET

Blog banner

american greatines

Blog banner

Dancing Classes In Mumbai

Blog banner

Some facts about Technology

Blog banner

Carrot Pickle With Raisins (lagan Nu Achar)

Blog banner

Traditional UNIX Scheduling

Blog banner

Simple STEM Activities for Toddlers That Spark Curiosity

Blog banner

MOVEMBER

Blog banner

What is service level Agreement?

Blog banner

Cache memory

Blog banner

A MODERN OPERATING SYSTEM

Blog banner

Top 5 Tech Innovations of 2018

Blog banner

MYNTRA

Blog banner

Android Application Components and Activity Lifecycle

Blog banner

Embracing the power of Modern Machine UNIX

Blog banner

Guidelines for a low sodium diet.

Blog banner

Cyber Security Standards

Blog banner

Virtual Memory

Blog banner

Instagram

Blog banner

How covid-19 impacted Social media ad spend forecast globally

Blog banner

Lifestyle of a photographer

Blog banner

Office Lunch Problems in Mumbai and How Tiffin Services Solve Them

Blog banner

Data Warehouse Bus Matrix

Blog banner

LiquidPlanner

Blog banner

LEMON PICKLE SWEET AND MILD HOT

Blog banner

evolution of operating system - Disha Parekh

Blog banner

Why Should You Schedule Tweets on Twitter?

Blog banner

Network Footprinting in Cybersecurity

Blog banner

Fitness

Blog banner

SmartData Collective: Data Science aur Analytics ki Duniya

Blog banner