some one please help

please help me and my code.
i don't know how the heck why this stuff doesn't work please some pro help
the code:I
I
V
int reanswer;
String q1 = "";
String q2 = "";
String q3 = "";
String q4 = "";
String final_answer = "";

void setup() {
Serial.begin(9600);
}

void loop()
{
delay(961);
reanswer = answering();
}
int answering() {
Serial.println("What Is 1+1");
while (!Serial.available())
{}
q1 = Serial.readString(); //Reading the Input string from Serial port.
Serial.println("What Is 2x2");
while (!Serial.available()) {}
q2 = Serial.readString();
Serial.println("What Is 1000x1000");
while (!Serial.available()) {}
q3 = Serial.readString();
Serial.println("What Is 87934435874537893457898793457893451135789231589235189345697734856752367491579634578935278934573458543x32475237823578013457037490790346780346324678034578034578098045389340594583");
while (!Serial.available()) {}
q4 = Serial.readString();
Serial.println("-------------------------"); //Showing the details
Serial.println("Your Answer To Question 1:" + q1);
Serial.println("Your Answer To Question 2:" + q2);
Serial.println("Your Answer To Question 3:" + q3);
Serial.println("Your Answer To Question 4:" + q4);
Serial.println("Are You Sure To Submit?");
Serial.println("Y For Yes AND N For N");
while (!Serial.available()) {}
final_answer = Serial.readString();
if (final_answer = "y") {
if (q1 == "2" && q2 == "4" && q3 == "1000000" && q4 == "2.855692e+174")
Serial.println("Good Job!");
else {
Serial.println("You Are So Bad!");
}
} else if (final_answer = "n") {
reanswer = answering();

Hi and welcome to the forum!

I don't know where to begin to help you here. First off, have a look at this link: Read this before posting a programming question ... - Programming Questions - Arduino Forum

and pay attention to #6. Getting help on the forum. Please use code tags to post your code.

Secondly, you haven't mentioned what your code is doing, or what it isn't doing. So, what is it doing, or not doing?

This bit of code appears to have mis-matched {}

    if (final_answer = "y") {
    if (q1 == "2" && q2 == "4" && q3 == "1000000" && q4 == "2.855692e+174")
    Serial.println("Good Job!");
       else {
      Serial.println("You Are So Bad!");
}
} else if (final_answer = "n") {
reanswer = answering();

Is your program even compiling?

Randy

note that the answer to the last question is

2855691717907788367543182352984578828428820640893192846550895280329553765783656751652971181865714742496049670860253779762943599085869199511407085460572102058633539622320872569

be precise!

:slight_smile:

 if (final_answer = "y") {

Easy mistake to make, = is an assigment, == is a comparison.

    if (q1 == "2" && q2 == "4" && q3 == "1000000" && q4 == "2.855692e+174")

Make sure the serial monitor is set to "No line ending", otherwise the line ending will get tacked onto the end of the text and all of those comparisons will be false.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.