Skip to content

Commit

Permalink
Merge pull request #46 from abhijitramesh/percentageissue
Browse files Browse the repository at this point in the history
Generalised the percentage logic
  • Loading branch information
immadisairaj committed Dec 30, 2018
2 parents 9164e71 + 8f9ff90 commit 970f3ea
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class QuizActivity extends AppCompatActivity {
Question qAndA = new Question();

int ques, score, ans, nextC;
float percentage;
boolean submit;

ArrayList<Integer> Answers;
Expand Down Expand Up @@ -254,7 +255,7 @@ public void clickSubmit(View view) {
if (submit)
checkScore();
submit = false;

percentage = (float)(score*100)/qAndA.question.size();
prevButton.setVisibility(View.INVISIBLE);
opA.setClickable(false);
opB.setClickable(false);
Expand All @@ -269,7 +270,7 @@ public void clickSubmit(View view) {
progressBar.setSecondaryProgress(10);
progressBar.setProgress(score);
progressBar.setProgressDrawable(drawable);
textView.setText(score + "0%");
textView.setText((int)percentage + "%");
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.setTitle("RESULT");
alert.setMessage("You scored "+score + " out of " + qAndA.question.size()+" questions.");
Expand Down

0 comments on commit 970f3ea

Please sign in to comment.