Skip to content

Instantly share code, notes, and snippets.

@udacityandroid
Created May 25, 2015 21:43
Show Gist options
  • Star 12 You must be signed in to star a gist
  • Fork 11 You must be signed in to fork a gist
  • Save udacityandroid/ebfe09973fe111264aef to your computer and use it in GitHub Desktop.
Save udacityandroid/ebfe09973fe111264aef to your computer and use it in GitHub Desktop.
Android Development for Beginners : Practice Set 2 Currency Conversion Example
int dollars = 40;
int dollarsToYen = 119;
int yen = dollarsToYen * dollars;
display(yen);
@nnannos
Copy link

nnannos commented Apr 9, 2017

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

@Mahmoudtarek59
Copy link

4760

@leoyats
Copy link

leoyats commented Sep 5, 2017

true

@gaietta80
Copy link

Correct. The result is 4760

@OldWolf55
Copy link

Yes , it works fine

@Gtstride
Copy link

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
Copy link

40*119 = 4760

@Nogaeman
Copy link

Nogaeman commented Feb 3, 2018

The Result Is
untitled

Copy link

ghost commented Feb 11, 2018

Perfect code

@abdahma01
Copy link

untitled

@peteribrahimgorgy
Copy link

correct convert
showing value of 4760

image

@first-hero
Copy link

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

@theiceman1010
Copy link

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

and then .setText("" + i);

@mustangmert
Copy link

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

@lakshmiprasannatirumala

code is correct.
The output is 4760

@conbradst
Copy link

int dollars = 40;

    int dollarsToYen = 119;

    int yen = dollarsToYen * dollars;

    display(yen);

40 x 119 = 4760

  • Correct codes

@Imsurajkr
Copy link

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
Copy link

The output is 4760

@Mohanad0
Copy link

1111
4760

@hero82
Copy link

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
Copy link

correct :4760
a

@ahmedmtaher
Copy link

4760

Copy link

ghost commented Jun 12, 2018

4760

@jerylee
Copy link

jerylee commented Jun 26, 2018

image

@dimenfer
Copy link

dimenfer 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
Copy link

this code also works fine:

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

@shaan0708
Copy link

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

@shiva-karthick
Copy link

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

@authentictech
Copy link

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