Skip to content

Instantly share code, notes, and snippets.

@udacityandroid
Last active February 3, 2023 09:49
Show Gist options
  • Star 52 You must be signed in to star a gist
  • Fork 32 You must be signed in to fork a gist
  • Save udacityandroid/90017426439d37728a29 to your computer and use it in GitHub Desktop.
Save udacityandroid/90017426439d37728a29 to your computer and use it in GitHub Desktop.
Android Development for Beginners : Define a Method
private String createCalendarEventReminder(String eventName, String location, int minutesAway) {
String reminder = "You have an upcoming event in " + minutesAway + " minutes.";
reminder = reminder + " It is " + eventName + " held at " + location + ".";
return reminder;
}
private int deductPoints(int pointsUsed) {
// Everyone starts with 100 points
int numberOfPoints = 100 - pointsUsed;
return numberOfPoints;
}
private String findTotalTripLength(int distanceOfFirstTrip, int distanceOfSecondTrip, int distanceOfThirdTrip) {
// Assume we need 2 miles to go to our friend's home (where the trip will start).
int totalLength = 2;
// Then start adding in the trip length.
totalLength = totalLength + distanceOfFirstTrip + distanceOfSecondTrip + distanceOfThirdTrip;
// Form a string to display the total trip length.
String message = "The total trip will be: " + totalLength + " miles.";
return message;
}
@dennisotugo
Copy link

dab dab dab dab dab dab dab

@adeadelina
Copy link

wow @pushpalroy thanks! glad i scrolled all the way here... I really couldn't see why my answers were incorrect

@Maxwe1
Copy link

Maxwe1 commented Feb 4, 2018

Working well. @pushpalory, I always make sure first that no white spaces around.

@abdahma01
Copy link

untitled

@badrddinb
Copy link

DONE

@rashibudati
Copy link

rashibudati commented Mar 4, 2018

oops
I am repeatedly getting error in the method 3. Is anything wrong?

@oddmentiusmaximus
Copy link

if anyone is getting an error on String,int,String in return data type then try writing the code without leaving any space after the types are written ,my answer was giving error because of the space after the word

@ashutoshshah18
Copy link

Getting the same error as posted above by rashibudati.

@louayeldin
Copy link

Awesome, Done!

@MrRobot-Root
Copy link

I keep getting Try Again Message on method 2 return Data Type which is int

@hudsonpereira
Copy link

Done

@iammahesh99
Copy link

done with it

@shoooka
Copy link

shoooka commented May 10, 2018

done

@Eduese
Copy link

Eduese commented May 21, 2018

Mr. Robot Root, you're supposed to follow instruction from the video and not to run the code. Thanks

Copy link

ghost commented May 25, 2018

This is cool, a lot of things to learn.

@eiadt
Copy link

eiadt commented May 29, 2018

3
4
Hi , I don't know why I have the wrong message ?

@amine2ng
Copy link

thank you so much

@tooptooptoop
Copy link

done

@MijeLafe
Copy link

MijeLafe commented Jun 8, 2018

done

@Fury4hwxc
Copy link

this is the correct answer
must be attention to uppercase
ashampoo_snap_2018 06 16_11h30m39s_001_android track - one million arab coders - udacity - mozilla firefox

Copy link

ghost commented Jun 20, 2018

Done

@alitariqali
Copy link

Done

@WasimNasrallah
Copy link

done

@emanhamad
Copy link

done
aaaa

@MostafaAtefsaber
Copy link

3
4
Hi , I don't know why I have the wrong message ?

I think you copied "String" to Return data type field by double click on "String"
in this case it copy String + space like that
utc
so remove this space

@driss65
Copy link

driss65 commented Dec 24, 2018

Make sure whene you copy-past to remove space at the end of words that you copy.

@MasterSami1985
Copy link

event we do correct , said not correct anyway I passed examin :)

@escobarfan
Copy link

who is doing in 2020?
during the pandemic
well, this course is going great.
abdullahjamil3810@gmail.com

@jasvan
Copy link

jasvan commented Jun 6, 2020

Todo bien gracias
Realizando cursos durante la pandemia

@surendra554
Copy link

Done

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