Chapter4 Switch ellipsis

From ArduinoInfo
Jump to navigation Jump to search
Note: Needed to retype several lines: dreaded "Stray "\" error: probably .doc has some invisible characters??

/* YourDuinoStarter Example: Switch with ellipsis
 - WHAT IT DOES: Test usinh switch with ellipsis
 - SEE the comments after "//" on each line below
 - CONNECTIONS: None
   -
 - V1.00 04/01/2015
   Questions: terry@yourduino.com */

/*-----( Declare Variables )-----*/

int   grade;        // The numeric value of the grade
char  letterGrade;  // The corresponding letter grade

void setup()   /****** SETUP: RUNS ONCE ******/
{
  Serial.begin(9600);
  Serial.println("Testing Numeric value to letter grade switch");
  grade = 89;  // Test by changing this

  switch (grade)
  {
    case 0 ... 59:

      letterGrade = 'F';
      break;
    case 60 ... 69:
      letterGrade = 'D';
      break;
    case 70 ... 79:
      letterGrade = 'C';
      break;
    case 80 ... 89:
      letterGrade = 'B';
      break;
    case 90 ... 100:
      letterGrade = 'A';
      break;
    default:
      Serial.println("Should never go here.");
      break;

  } // END switch

  Serial.print("Integer Value = " );
  Serial.print(grade);
  Serial.print("  Letter Grade = " );
  Serial.println(letterGrade);

}//--(end setup )---


void loop()   /****** LOOP: RUNS CONSTANTLY ******/
{
// Nothing here!
}//--(end main loop )---

/*-----( Declare User-written Functions )-----*/
//None

//*********( THE END )***********