-
-
Save udacityandroid/ebfe09973fe111264aef to your computer and use it in GitHub Desktop.
int dollars = 40; | |
int dollarsToYen = 119; | |
int yen = dollarsToYen * dollars; | |
display(yen); |
in the display method you have to have display(int + i)
and then .setText("" + i);
Could you please share the working xml and Main activity codes showing how you tried.
Thanks
code is correct.
The output is 4760
int dollars = 40;
int dollarsToYen = 119;
int yen = dollarsToYen * dollars;
display(yen);
40 x 119 = 4760
- Correct codes
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);
}
The output is 4760
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)
4760
4760
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.
this code also works fine:
int dollars = 40;
int dollarsToYen = 119;
display (dollarsToYen * dollars);
@shaan0708 one of your closing braces are missing, check them!
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.
Perfect code