Lab Assignment 3

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 3

Lab Assignment 3

CSC305: Programming Paradigms


Logic Programming

Answer ALL questions. This is a group assignment.


Provide the answer for the following question by using only PROLOG programming
language provided in the lab.

Question 1
Consider the following facts.

Add the following rules and get the output by using console.
1. A student is an excellent student if she/he is a dean list student.
2. A student is an active student if she/he involves in any committee.
3. Get who is the DCS coordinator?
4. Get who is the DICE coordinator?
5. Get who is the active student in DCS program?
6. Get who is the excellent student in DCS program?
7. Get who is the excellent student in DICE program?
8. Get who is involved in the college committee?
9. Get who is involved in the seminar committee?

Lab Assignment 4
CSC305: Programming Paradigms
Functional Programming

Answer ALL questions. This is a group assignment.


Provide the answer for the following question by using only Scheme programming language
provided in the lab.

Question 1

Explain the use of arithmetic expressions and Input Output in Scheme language. Give an
example to support your answer. Also show the difference between functional and imperative
languages in both aspects.

Question 2

Write a program that converts degrees to radians using the formula below.

radians = degrees / 57.3

Question 3

Write a program that input an integer and display for the user whether the number is even or
odd.

Question 4

Write a program that calculates simple interest (I = PRT) given the principal, the interest rate
and period of years.

Question 5

Write a program that calculates the current through a resistor given the voltage drop across
the resistor and the resistance in ohms. Use the formula I = V/R where V is voltage, R is
resistance in ohms and I is current in amps.

Question 6

Write a program that calculates force (f = ma), where F is force in Newton’s, m is mass in
kilogram and a is acceleration in meter/second.

Question 7

Write a program that uses Einstein’s e = mc2 equation to find the amount of energy for a
given mass.

Question 8
Steel manufacturing tapes vary in length slightly depending on the temperature. When they
are manufactured, they are standardized for 20 degrees Celsius (68 degrees Fahrenheit). As
the temperature varies above or below 20 degrees C, the tape becomes slightly inaccurate,
which must be taken into consideration. The formula below will produce a length correction
given the length measured by the tape and the temperature in Fahrenheit.
(T = temperature, L = measured length)

C = 0.0000116 *(T – 20) * L

The adjusted length can be calculated using the following formula.

new length = L + C

Write a function to input the measured length and temperature in Celsius and outputs and
adjusted length using the formula above.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy