Question

In: Computer Science

SWITCH CASE, WHILE, DO WHILE STRUCTURES, using ARDUINO. Urgent Please! Implement the following programs, attach a...

SWITCH CASE, WHILE, DO WHILE STRUCTURES, using ARDUINO. Urgent Please!

Implement the following programs, attach a flow chart, and photos of its operation.
1. Read a number that represents the month and say what months it is.
2. Using the conditional "while" calculate the factorial of a number
3. Using the “do-while” conditional, make a program that prints all numbers from 1 up to a maximum number entered by the user.

Solutions

Expert Solution

PROGRAM 1:



void setup() {
     Serial.begin();
  // modify it according to yourself

}

void loop() {
     Serial.println("Input Month No :");
      int mon_num=Serial.read();
    
   switch(mon_num)
   {
        case 1:
               Serial.println("January");
               break;
        case 2:
               Serial.println("February");
               break;
        case 3:
               Serial.println("March");
               break;
        case 4:
               Serial.println("April");
               break;
        case 5:
               Serial.println("May\n");
               break;
        case 6:
               Serial.println("June");
               break;
        case 7:
               Serial.println("July");
               break;
        case 8:
               Serial.println("August");
               break;
        case 9:
               Serial.println("September");
               break;
        case 10:
               Serial.println("October");
               break;
        case 11:
               Serial.println("November");
               break;
        case 12:
               Serial.println("December");
               break;
        default:
               Serial.println("INvalid Input");
               break;
}

PROGRAM 2



void setup() {
       Serial.begin();
  // modify it according to yourself

}

void loop() {
    int n;
          Serial.println("ENTER A NUMBER:");
          n=Serial.read();
        int fact = 1;
        while(n>1)
        {
            fact=fact*n;
            n--;
        }
        Serial.println(fact);
}


FLOWCHART

PROGRAM 3

void setup() {
      Serial.begin();
  // modify it according to yourself
}

void loop() {
    int n;
    Serial.println("Enter number of elements you want to enter:");
          n=Serial.read();
          int a[n];

        int max = -99999;
        int i = 0;
        do{
            Serial.println("ENTER NUMBER:");
            Serial.println(i+1);
            a[i]=Serial.read();
            if(a[i] > max)
            {
                max=a[i];
            }
            i++;
        }while(i!=n);
        Serial.println("Larger number = ");
  Serial.println(max);
}

FLOWCHART


Related Solutions

SWITCH CASE, WHILE, DO WHILE STRUCTURES Implement the following programs, attach a flow chart, and photos...
SWITCH CASE, WHILE, DO WHILE STRUCTURES Implement the following programs, attach a flow chart, and photos of its operation. 1. Read a number that represents the month and say what months it is. 2. Using the conditional "while" calculate the factorial of a number 3. Using the “do-while” conditional, make a program that prints all numbers from 1 up to a maximum number entered by the user.
The following is a set of tree-set test programs that show the following outputs: Switch to...
The following is a set of tree-set test programs that show the following outputs: Switch to ArrayList, LinkedList, Vector, TreeMap, and HashMap to display similar output results. Results: Tree set example! Treeset data: 12 34 45 63 Treeset Size: 4 First data: 12 Last Data: 63 Removing data from a tree set Current tree set elements: 12 34 63 Current tree set size :3 Tree set empty. Example code import java.util.Iterator; import java.util.TreeSet; public class TreeDemo2 { public static void...
C++(screenshot output please) Part 2 - Tree programs Program 1 Implement a tree using an array...
C++(screenshot output please) Part 2 - Tree programs Program 1 Implement a tree using an array Program 2 Implement a tree using linked list - pointer Binary Tree Program 3 - Convert program 1 to a template
Linked List Course Outcome: CLO3    Build computer programs to implement appropriate data structures for solving computing...
Linked List Course Outcome: CLO3    Build computer programs to implement appropriate data structures for solving computing problems in a time frame given. (P3, PLO3) Task Write a complete program by applying linked list data structure that will perform the following operation on any records: Add record Delete record View record Find record Your program also should be able to display the number of record in the linked list. Put your creativity to produce the program. Your Submission should have the...
***Using Java Using the switch/case construct, write a program that takes a character from the user...
***Using Java Using the switch/case construct, write a program that takes a character from the user and classifies it as a number (‘1’,’2’, ‘3’, …), a letter from the alphabet (‘A’, ‘a’, ‘B’, ‘b’, …, ‘Z’, ‘z’), an arithmetic operator (‘+’, ‘-‘, ‘/’, ‘*’, ‘%’), a comparison operator (‘<’, ‘>’, ‘=’), punctuation (‘!’, ‘?’, ‘,’, ‘,’, ‘:’, ‘;’), and all other characters as a Special Character, and informs the user of the same. If the user entered the character A,...
The course is Data Structures and am using Javascript and Atom... QUESTION 1. Implement the dictionary...
The course is Data Structures and am using Javascript and Atom... QUESTION 1. Implement the dictionary data structure using the prototype. Run some tests that show that your code works. 2. Implement the hash table data structure using the prototypeRun some tests that show that your code works. 3. The book discusses linear probing, but their approach has a serious problem. What is the issue? 4. Complete the method below that adds all key-value pairs from one dictionary into another....
C++ Data Structures: Implement a Stack and a Queue using Linked list In this lab you...
C++ Data Structures: Implement a Stack and a Queue using Linked list In this lab you will implement the functionality of a stack and a queue using a linked list. Your program must use of the declaration of the Stack and Queue class in Stack.h and Queue.h You have to implement the functionalities of queue (enq, deq, displayQueue) in a file called Queue.cpp. All the functions in Queue.cpp should follow the prototypes declared in Queue.h. Your code should make use...
C coding • Implement, using structures and functions as appropriate, a program which requires you to...
C coding • Implement, using structures and functions as appropriate, a program which requires you to enter a number of points in 3 dimensions. The points will have a name (one alphanumeric character) and three coordinates x, y, and z. Find and implement a suitable way to stop the input loop. The program, through an appropriate distance function, should identify the two points which are the furthest apart. Another function should calculate the centre of gravity of the point cloud...
Explain why dyes attach to natural fibers more readily than synthetic fibers. How do the structures relate?
Explain why dyes attach to natural fibers more readily than synthetic fibers. How do the structures relate?
how to read, write and append a text file using a switch case in java.I need...
how to read, write and append a text file using a switch case in java.I need help with the code.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT