Functional Programming Answers

Questions: 109

Answers by our Experts: 81

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search & Filtering

Modify the example in Adruino to such that when the motors turn clockwise, the green light blinks, and when the motor turns counter-clockwise, the red light blinks.

Example:

void setup() {

prizm.PrizmBegin(); // Initialize the PRIZM controller
}

void loop() { // repeat in a loop

prizm.setMotorPower(1,25); // spin Motor 1 CW at 25% power
delay(5000); // wait while the motor runs for 5 seconds
prizm.setMotorPower(1,0); // stop motor (coast to stop)
delay(2000); // After stopping, wait here for 2 seconds
prizm.setMotorPower(1,-25); // spin Motor 1 CCW at 25% power
delay(5000); // wait while the motor runs for 5 seconds
prizm.setMotorPower(1,0); // stop motor (coast to stop);
delay(2000); // After stopping, wait here for 2 seconds, then repeat

}
Modify the example in the Arduino to such that the red LED light flashes 3 times for 0.5 seconds, followed by 2 one-second flashes of the green LED light.

Example:
/* PRIZM Controller example program
* Blink the PRIZM red LED at a 1 second flash rate
* author PWU on 08/05/2016
*/

#include <PRIZM.h> // include the PRIZM library

PRIZM prizm; // instantiate a PRIZM object "prizm" so we can use its functions

void setup() {

prizm.PrizmBegin(); // initialize the PRIZM controller

}

void loop() { // repeat this code in a loop

prizm.setRedLED(HIGH); // turn the RED LED on
delay(1000); // wait here for 1000ms (1 second)
prizm.setRedLED(LOW); // turn the RED LED off
delay(1000); // wait here for 1000ms (1 second)


}
At the start of each year, a list of units offered by a university is provided its students.
The students check the units available, and enrol in the units that are part of their degrees.

The timetable of classes for each unit is provided by the Class Management office.
Each unit has a few available classes that run at different days during the week.
Students check the class schedule and register for a class of their choice. They get a
confirmation after they have registered for their classes.

The academic staff members coordinating units check the class registrations during class
registration week. They inform the Class Management office to open or close classes if
needed. They also get a list of students registered in each of their classes once registrations
are closed. They also get a list of students enrolled in each of their units at census date.
What are the basic data types inFORTRAN?

1. Integer, Real, Complex, Character

2. Integer, Real, Double, Precision

3. Integer, Real, Logical, Character
Which of the following is invalid statement in FORTRAN?

(A). Do 10001=15
(B). CONTINUE
(C). P+Q+
(D). DIMENSION×(30,20)
Question 2 (Marks: 50)
The system to be developed for Williams and Son needs to produce the following slip for a
customer once the sale has been concluded.
Please note: For the purpose of this assignment, assume that a customer will only purchase one
unit of each item.
Q.2.1 Write the pseudocode that will produce a slip similar to the one illustrated at
the beginning of the question. Your solution should satisfy the following
requirements:
 The solution must illustrate the use of good programming practices;
 The solution must make use of a loop;
 The loop must make use of a sentinel value.

Q.2.2 The mainline logic of almost every procedural program consists of three parts
namely housekeeping tasks, detail loop tasks and end-of-job tasks. By making
use of flowcharts, show how these parts can be implemented in your solution
for Question 2.1.

Q.2.3 All of your solutions should be structured. Explain why your solution can be
considered a structured solution.
g(0, Y, Y):- !.
g(X, C, R):- Y is X - 1, C1 is C * 2, g(Y, C1, R).

What is the final value of Y after g(3, 2, Y)?
Many devices are build and programmed with another computer than How the first computer was programmed to do something?
1. When the following are true? The following symbols are used:
~ - negation,
v – disjunction,
& - conjunction,
-> - implication

1. p & ~p v q

2. ~(x v y) = ~x & ~y
3. ~( a -> ~b)

For each of the following, under what circumstances are they TRUE
For example, question 1 is true only when q is true

TRUE 1, FALSE 0

This is about boolean logic

Conjunction: a AND b, a ∩ b, a & b, a && b
True only if both a and b are true
Disjunction: a OR b, a ∪ b, a || b ,
False only if both a and b are false
Negation: NOT a
True only if a is false
Implication: a IMPLIES b
False only when a true and b false
Equivalence: a IS EQUIVALENT TO b, a = b, a == b ,
True when a and b are the same
LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS