Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7553083
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T10:57:08+00:00 2026-05-30T10:57:08+00:00

Bassicly i want the user to input 4 and then display the next question

  • 0

Bassicly i want the user to input “4” and then display the next question but when the user }
q=1;

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T10:57:09+00:00Added an answer on May 30, 2026 at 10:57 am

    An else if might work (depending on if this is in a loop or what) but the most important thing here to learn is how the && operator works. When you have two statements separated by && the one appearing first will execute first.. If the result is false the second statement will not execute at all. However you don’t want to ask the question at all in the second if statement if q == 0

    Since you are comparing what the user entered within the if statement, what is happening is that even though the question == 0 the second part of the if is not executing until after you asked the question.
    You should be the q == ? condition first in both cases (or if there are only 2 questions use else as shown by brawk1990)

    I would at least change your code to this:

    if (q == 0 && "4".equals(answer.getText().toString()))
    {
        display1.setText("Correct");
        display.setText("4 + 9 =");
        answer.setText("");
        score++;
        q=1;
    } 
    if (q == 1 && "13".equals(answer.getText().toString())){
        display1.setText("Incorrect");
    }
    

    There are a lot of better ways to do this though but this looks like some kind of homework so I’m guessing you have to do it a certain way. As someone else suggested I think a case statement would be better, but we really need to see more of the program/assignment to give good advice there.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Bassicly i want to print 1 then 2 then 3 then 4 incrementing when
Bassicly my aim is too extend a activity so when the user presses Next
Its maybe not the best solution in most cases, but i want a table
The code below basicly animates a div back and forth. Then I want the
I need to redirect an user, but I need to simulate some form processing,
I want a user to submit multiple form at once by submitting a master
I have four input fields: MaxWidth MaxHeight and Width Height I want to validate
I have a class which does operations on the database, but I want to
#define HISTORY_SIZE 50 #define INPUT_SIZE 512 /*Max input size*/ char input[INPUT_SIZE]; /*Holding user input
I want to stream a video from Facebook to my site and use my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.