Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Android Development for Beginners : Practice Set 2 Currency Conversion Example
int dollars = 40;
int dollarsToYen = 119;
int yen = dollarsToYen * dollars;
display(yen);
@nnannos

This comment has been minimized.

Copy link

@nnannos nnannos commented Apr 9, 2017

Program is correct, displays 4760, it is the result of 119*40

@Mahmoudtarek59

This comment has been minimized.

Copy link

@Mahmoudtarek59 Mahmoudtarek59 commented Aug 17, 2017

4760

@leoyats

This comment has been minimized.

Copy link

@leoyats leoyats commented Sep 5, 2017

true

@gaietta80

This comment has been minimized.

Copy link

@gaietta80 gaietta80 commented Dec 28, 2017

Correct. The result is 4760

@OldWolf55

This comment has been minimized.

Copy link

@OldWolf55 OldWolf55 commented Dec 29, 2017

Yes , it works fine

@Gtstride

This comment has been minimized.

Copy link

@Gtstride Gtstride commented Jan 2, 2018

Please, I don't seems to understand what line of code is to be written, because, all I have tried isn't going through

@isijackson

This comment has been minimized.

Copy link

@isijackson isijackson commented Jan 23, 2018

40*119 = 4760

@Nogaeman

This comment has been minimized.

Copy link

@Nogaeman Nogaeman commented Feb 3, 2018

The Result Is
untitled

@ghost

This comment has been minimized.

Copy link

@ghost ghost commented Feb 11, 2018

Perfect code

@abdahma01

This comment has been minimized.

Copy link

@abdahma01 abdahma01 commented Feb 13, 2018

untitled

@peteribrahimgorgy

This comment has been minimized.

Copy link

@peteribrahimgorgy peteribrahimgorgy commented Feb 18, 2018

correct convert
showing value of 4760

image

@first-hero

This comment has been minimized.

Copy link

@first-hero first-hero commented Feb 24, 2018

correct
int dollars = 40
int dollarsToYen = 119;
int yen = dollarsToYen * dollars;.............................40*119=4760
display(yen);........................=4760
screenshot_20180224-094848 1

@theiceman1010

This comment has been minimized.

Copy link

@theiceman1010 theiceman1010 commented Mar 11, 2018

in the display method you have to have display(int + i)

and then .setText("" + i);

@mustangmert

This comment has been minimized.

Copy link

@mustangmert mustangmert commented Mar 25, 2018

Could you please share the working xml and Main activity codes showing how you tried.
Thanks

@lakshmiprasannatirumala

This comment has been minimized.

Copy link

@lakshmiprasannatirumala lakshmiprasannatirumala commented Mar 29, 2018

code is correct.
The output is 4760

@conbradst

This comment has been minimized.

Copy link

@conbradst conbradst commented Apr 6, 2018

int dollars = 40;

    int dollarsToYen = 119;

    int yen = dollarsToYen * dollars;

    display(yen);

40 x 119 = 4760

  • Correct codes
@Imsurajkr

This comment has been minimized.

Copy link

@Imsurajkr Imsurajkr commented Apr 15, 2018

int dollars = 40;
int dollarsToYen = 119;
int yen = dollarsToYen * dollars;
display(yen);

// After this code, you have to add
public void display(int i) {
TextView t = (TextView) findViewById(R.id.display_text_view);
t.setText("" + i);
}

@mohamedsaleh1984

This comment has been minimized.

Copy link

@mohamedsaleh1984 mohamedsaleh1984 commented May 17, 2018

The output is 4760

@Mohanad0

This comment has been minimized.

Copy link

@Mohanad0 Mohanad0 commented May 26, 2018

1111
4760

@hero82

This comment has been minimized.

Copy link

@hero82 hero82 commented Jun 1, 2018

int dollars = 40;
int dollarsToYen = 119;
int yen = dollarsToYen * dollars;
display(yen);
// After this code, you have to add
public void display(int i) {
TextView t = (TextView) findViewById(R.id.display_text_view);
t.setText("" + i);
}
whay i (int i)

@tooptooptoop

This comment has been minimized.

Copy link

@tooptooptoop tooptooptoop commented Jun 2, 2018

correct :4760
a

@ahmedmtaher

This comment has been minimized.

Copy link

@ahmedmtaher ahmedmtaher commented Jun 7, 2018

4760

@ghost

This comment has been minimized.

Copy link

@ghost ghost commented Jun 12, 2018

4760

@jerylee

This comment has been minimized.

Copy link

@jerylee jerylee commented Jun 26, 2018

image

@diegomenfer

This comment has been minimized.

Copy link

@diegomenfer diegomenfer commented Oct 17, 2018

Hi @jerylee.
I tried to replicate what you did with your Layout, how do you get the .java to work with the layout?
cause when I changed the references to match the new ids in activity_main.xml, the application crashed, but without errors in Android Studio.
If could clarify that, I'll be grateful.

@josephmaayo

This comment has been minimized.

Copy link

@josephmaayo josephmaayo commented Oct 31, 2018

this code also works fine:

    int dollars = 40;
    int dollarsToYen = 119;
    display (dollarsToYen * dollars);
@shaan0708

This comment has been minimized.

Copy link

@shaan0708 shaan0708 commented Nov 23, 2018

Hii
I write the code correctly but i am getting the error in display
what should i do ?
screenshot 69 _li

@shankar-shiv

This comment has been minimized.

Copy link

@shankar-shiv shankar-shiv commented Dec 23, 2018

@shaan0708 one of your closing braces are missing, check them!

@authentictech

This comment has been minimized.

Copy link

@authentictech authentictech commented Mar 5, 2019

Kindly delete and do not post the answers to Udacity quizzes on these pages. It is not helpful to those who come here to get the code to see the answers before they have tried to answer the quiz for themselves.

The answer is provided on the next page in Udacity anyway - it is of no help to see it here. There is a Udacity forum to discuss the quiz if you need help.

I realize these are old posts but people are still doing the Udacity courses. The forum mods should remove the comments giving answers.

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