Computers and Technology

Modify the program so that it can do any prescribed number of multiplication operations (at least up to 25 pairs). The program should have the user first indicate how many operations will be done, then it requests each number needed for the operations. When complete, the program should then return "done running" after displaying the results of all the operations in order. It is in the Arduino Language

You can write the code from scratch if you'd like without modifying the given code. In any expected output.

//Initializing the data
float num1 = 0;
float num2 = 0;
int flag1 = 0;

// a string to hold incoming data
String inputString = " ";
// Whether the string is Complete
boolean stringComplete = false;
//This is where the void setup begins
void setup() {
//Initializing the serial
Serial. begin (9600);
//Reserving 200 bytes for the inputString
inputString. reserve (200);
Serial. println("Provide The First Number");
}

void loop() {
//Print the string when the new line arrives
if (stringComplete) {
if (flag1 == 0) {
Serial. println(inputString);
num1 = inputString. toFloat( );
flag1 = 1;
//Asking the user to input their second string
Serial. println("Provide The Second Number");
}
else if (flag1 == 1) {
Serial. println(inputString);
num2 = inputString. toFloat( );
flag1 = 2;
Serial. println("The Product is Calculating...");
}
if (flag1 == 2) {
Serial. println("The Product is: ");
Serial. println(num1*num2);
Serial. println("Press Reset");
flag1 = 5;
}
//This clears the string
inputString = " ";
stringComplete = false;
}
}

void serialEvent() {
while (Serial. available( )) {
// get the new byte
char inChar = (char)Serial. read( );
//add it to the inputString
inputString += inChar;
//if the incoming character is a newline, set a flag so the main loop can
//do something about it

if (inChar == '\n') {
stringComplete = true;
}
}
}

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 07:20, Hcalhoun21
Write a pseudocode solution for each of these problems. 1. design a while loop that lets that user enter a number. the number should be multiplied by 10, and the result stored in a variable named product. the loop should iterate as long as product contains a value less than 100. 2. design a do-while loop that asks the user to enter two numbers. the numbers should be added and the sum displayed. the loop should ask the user whether he or she wishes to perform the operation again. if so, the loop should repeat; otherwise it should terminate. 3. design a for loop that displays the following set of numbers: 0, 10, 20, 30, 40, 50 100. 4. design a nested loop that displays 10 rows of # characters. there should be 15 # characters in each row. 5. convert this for loop to a while loop. declare integer count for count = 1 to 50 display count end for 6. find the error in the following pseudocode. declare boolean finished = false declare integer value, cube while not finished display “enter a value to be cubed.” input value; set cube = value ^ 3 display value, “ cubed is “, cube end while
Answers: 2
image
Computers and Technology, 22.06.2019 22:50, youngboymark123
Assume the existence of a bankaccount class. define a derived class, savingsaccount that contains two instance variables: the first a double, named interestrate, and the second an integer named interesttype. the value of the interesttype variable can be 1 for simple interest and 2 for compound interest. there is also a constructor that accepts two parameters: a double that is used to initialize the interestrate variable, and a string that you may assume will contain either "simple", or "compound", and which should be used to initialize the interesttype variable appropriately. there should also be a pair of functions getinterestrate and getinteresttype that return the values of the corresponding data members (as double and int respectively).
Answers: 2
image
Computers and Technology, 23.06.2019 15:30, PlzNoToxicBan
The song about casey jones a railroad engineer who gives his life on the job would most likely gall under the folk song category of? a-work song b-nonsense song c-religious song d-ballad
Answers: 1
image
Computers and Technology, 24.06.2019 07:00, AnaiyaKirksey8
You are most likely to automatically encode information about
Answers: 1
Do you know the correct answer?
Modify the program so that it can do any prescribed number of multiplication operations (at least up...

Questions in other subjects:

Konu
Mathematics, 06.05.2020 23:59