Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Android for Beginners : If/Else Email Quiz
int numberOfEmailsInInbox = 0;
int numberOfDraftEmails = 2;
String emailMessage = "You have " + numberOfEmailsInInbox + " emails. ";
String draftMessage = "You have " + numberOfDraftEmails + " email drafts.";
if (numberOfEmailsInInbox == 0) {
emailMessage = "You have no new messages. ";
}
if (numberOfDraftEmails == 0) {
draftMessage = "You have no new drafts.";
}
Log.v("InboxActivity", emailMessage);
Log.v("InboxActivity", draftMessage);
@vipivoxa
Copy link

vipivoxa commented Feb 8, 2018

definitely the correct answer is A, B or C !!!

@Maxwe1
Copy link

Maxwe1 commented Feb 8, 2018

Done

@Nogaeman
Copy link

Nogaeman commented Feb 16, 2018

You have no new messages.
You have 2 email drafts.

@abdahma01
Copy link

abdahma01 commented Feb 24, 2018

You have no new messages.
You have 2 email drafts.

@Alimamasy
Copy link

Alimamasy commented Feb 24, 2018

The answer is C.
Fine.

@badrddinb
Copy link

badrddinb commented Mar 7, 2018

done

@louayeldin
Copy link

louayeldin commented Mar 18, 2018

You have no new messages.
You have 2 email drafts.

@xbarakota
Copy link

xbarakota commented Mar 18, 2018

C

@pinedalezephyr
Copy link

pinedalezephyr commented Mar 21, 2018

What I have found some days is that the answers posted are more trouble than help, anyway we are here to work our way through, Remember no matter how hard it is we are still to have fun. Feel free to pick my brain if you need help, as many times I have had to pick my programmer son's brains when I could not see something simple.

@apitimur
Copy link

apitimur commented Mar 23, 2018

Admin advised others to not answer it, but many users need more care and affection. Lol

@ahmedmofreh
Copy link

ahmedmofreh commented Mar 31, 2018

You have no new messages.
You have 2 email drafts.

@Shakthivanilla
Copy link

Shakthivanilla commented Mar 31, 2018

Option C is wrong. I think Katherine and Kunal made a boo boo in providing their options. Line number 5's output is true so it will enter the code block and it will print line no 6. All right! Now see Line No. 13 is not inside a if else block and so is Line No. 14. So the correct answer is Line no. 6, Line No. 13 and Line. No. 14. Please let me know If I am missing something here.

@lakshmiprasannatirumala
Copy link

lakshmiprasannatirumala commented Apr 3, 2018

Dealing with if else conditional statements is quite interesting. we are able to improve our knowledge.

@tanveertkd
Copy link

tanveertkd commented Apr 9, 2018

Please don't put the answers in the comments. There are still people that are taking this course. Let them learn.

@Gaganindoriya
Copy link

Gaganindoriya commented May 5, 2018

You have no new messages
You have 2 email drafts

@shoooka
Copy link

shoooka commented May 15, 2018

Please don't put the answers in the comments. There are still people that are taking this course. Let them learn.
ok i do

@arnolde
Copy link

arnolde commented May 28, 2018

I can't believe how many people are too dumb to have understood the rules (no answer posting) by now... it's pretty far into the course already... hope they get disqualified ;-)

@ahossam88
Copy link

ahossam88 commented Jun 22, 2018

I solve it

@MohEbaid
Copy link

MohEbaid commented Jun 26, 2018

You have no new messages.
You have 2 email drafts.

@mudathirlawal
Copy link

mudathirlawal commented Jun 26, 2018

I first got confused because I forgot that their is a special IF structure for when the variable, numberOfEmailsInInbox, holds a value of 0.
And, so, I expected the displayed string to be: "You have 0 emails"; but, I quickly understood the thought process once I looked at the code
again and noticed the IF structure:
if (numberOfEmailsInInbox == 0) {
emailMessage = "You have no new messages. ";
}
It is quite a cool code!

@Fury4hwxc
Copy link

Fury4hwxc commented Jun 26, 2018

thanks 👍

@dantj007
Copy link

dantj007 commented Jun 29, 2018

The answer is option C.
You have no new messages.
You have 2 email drafts.

@Tchybooxur
Copy link

Tchybooxur commented Jul 4, 2018

Clearly C

@emanhamad
Copy link

emanhamad commented Sep 12, 2018

C

@YassineOuardini
Copy link

YassineOuardini commented Apr 9, 2019

C

@AhmedMohammed11
Copy link

AhmedMohammed11 commented Apr 12, 2019

You have no new messages.
You have 2 email drafts.

@allouane
Copy link

allouane commented Jun 4, 2020

You have no new messages.
You have 2 email drafts.

@mixspark
Copy link

mixspark commented Mar 21, 2021

ok

@zake0000
Copy link

zake0000 commented Apr 7, 2021

الكل يكتب الاجابة اصبحتوا علماء فالبرمجة الان ههه مفيش حد هيفهمني انان عارف غير لو عربي طبعا

@Harriskobia
Copy link

Harriskobia commented Apr 21, 2022

Option C is correct:

V/InboxActivity : You have no new messages.
V/InboxActivity : You have 2 email drafts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment