Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Arduino Part I Binary Puzzles All functions work correctly (45 points) shiftRight(int num, int n) shiftLeft(int num, int n) hasAOne(int num) hasAZero(int num) leastSigHasAOne(int num)

Arduino

  • Part I Binary Puzzles
    • All functions work correctly (45 points)
      • shiftRight(int num, int n)
      • shiftLeft(int num, int n)
      • hasAOne(int num)
      • hasAZero(int num)
      • leastSigHasAOne(int num)
      • isNegativeInt(int num)
      • isNegativeLong(long num)
      • isNegativeChar(char num)
      • negate(int num)
  • Part II Binary Counter
    • Drawn FSM (20 points)
      • 16 states
      • correctly models the counter
    • FSM (30 points)
      • determineNextState() filled out and working
      • 16 states
      • uses enums
      • switches from state to state with a switch or if statements
      • working counter printed out in the Serial Monitor
    • Reverse Button / Lever (5 points)
      • can switch the direction of the counter
  • All of your files are committed

  1. Assignment Demo
0 : 000 1 : 001 2 : 010 3 : 011 4 : 100 --Reverse-- 3 : 011 2 : 010 1 : 001 --Reverse-- 2 : 010 3 : 011 --Reverse-- 2 : 010 1 : 001 0 : 000 7 : 111 6 : 110 5 : 101 --Reverse-- 6 : 110 7 : 111 0 : 000 --Reverse-- 7 : 111 6 : 110 5 : 101 4 : 100

void setup() { Serial.begin(9600); // put your setup code here, to run once:

}

void loop() { // put your main code here, to run repeatedly:

//Test: Serial.println(); Serial.print("shiftRight(5,1) should return 2: "); Serial.println(shiftRight(5,1)); Serial.print("shiftRight(7,4) should return 0: "); Serial.println(shiftRight(7,4));

Serial.println(); Serial.print("shiftLeft(5,2) should return 20: "); Serial.println(shiftLeft(5,2)); Serial.print("shiftLeft(-1,1) should return -2: "); Serial.println(shiftLeft(-1,1));

Serial.println(); Serial.print("hasAOne(4) should return 1: "); Serial.println(hasAOne(4)); Serial.print("hasAOne(0) should return 0: "); Serial.println(hasAOne(0));

Serial.println(); Serial.print("hasAZero(5) should return 1: "); Serial.println(hasAZero(5)); Serial.print("hasAZero(-1) should return 0: "); Serial.println(hasAZero(-1)); Serial.println(); Serial.print("leastSigHasAOne(255) should return 1: "); Serial.println(leastSigHasAOne(255)); Serial.print("leastSigHasAOne(256) should return 0: "); Serial.println(leastSigHasAOne(256));

Serial.println(); Serial.print("isNegativeInt(-500) should return 1: "); Serial.println(isNegativeInt(-500)); Serial.print("isNegativeInt(500) should return 0: "); Serial.println(isNegativeInt(500));

Serial.println(); Serial.print("isNegativeLong(-40000) should return 1: "); Serial.println(isNegativeLong(-40000)); Serial.print("isNegativeLong(40000) should return 0: "); Serial.println(isNegativeLong(40000));

Serial.println(); Serial.print("isNegativeChar(-5) should return 1: "); Serial.println(isNegativeChar(-5)); Serial.print("isNegativeChar(1) should return 0: "); Serial.println(isNegativeChar(1));

Serial.println(); Serial.print("negate(-500) should return 500: "); Serial.println(negate(-500)); Serial.print("negate(500) should return -500: "); Serial.println(negate(500));

}

// int shiftRight(int num, int n){ return num; }

int shiftLeft(int num, int n){ return num; }

// Fix the following functions, using only the bitwise and Boolean operators int hasAOne(int num) { return num; }

int hasAZero(int num) { return num; }

int leastSigHasAOne(int num) { return num; }

int isNegativeInt(int num) { return num; }

int isNegativeLong(long num) { return num; }

int isNegativeChar(char num) { return num; }

int negate(int num) { return num; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Essential SQLAlchemy Mapping Python To Databases

Authors: Myers, Jason Myers

2nd Edition

1491916567, 9781491916568

More Books

Students also viewed these Databases questions

Question

How many stores exceeded the KPI target in 2015?

Answered: 1 week ago