Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Use an EditTextPreference element How to Add an EditTextPreference element for a

ID: 3598407 • Letter: U

Question

Use an EditTextPreference element

How to Add an EditTextPreference element for a setting named Name in preferences.xml file in the xml directory. This setting should allow the user to enter his or her full name. Run the app and use the Settings activity to enter your name. Open the layout of the activity. Modify the layout, so it includes a fifth row that can display a name. Open the class for the Tip Calculator activity. Modify this code so it gets the name from the preferences and displays that name in preferences.xml.

Thanks.

Explanation / Answer

package com.one;

public class X00000000 extends Polynomial {

public static void main(String args[]) throws Exception {

Polynomial p = new X00000000(" X^5"), q = new X00000000("X^2 - X + 1");

Utility.run(p, q);

}

public X00000000(String s) {

// parse string character by character

double coef = 0; // coefficient of term

int deg = 0; // degree of term

String[] terms = s.split(" ");

for (int i = 0; i < terms.length; i++) {

String term = terms[i];

// System.out.println("term:"+term);

String prevTerm = "";

if (i != 0)

prevTerm = terms[i - 1];

if (term.startsWith("X")) {

if (term.length() == 3 && term.contains("^")) {

coef = 1;

deg = Integer.parseInt(term.substring(2));

} else if (term.length() == 1) {

deg = 1;

if (prevTerm.equals("-"))

coef = -1;

else

coef = 1;

}

} else if (term.startsWith("-") || term.startsWith("+"))

continue;

else if (term.length() == 1 && Character.isDigit(term.charAt(0))) {

coef = Integer.parseInt(term);

if (prevTerm.equals("-"))

coef *= -1;

deg = 0;

}

Term T = new Term(coef, deg);

if (data.isEmpty()) {

data.addFirst(T);

} else {

data.addLast(T);

}

}

}

public X00000000() {

super();

}

public Polynomial add(Polynomial p) {

Polynomial ans = new X00000000();

// complete this code

return ans;

}

public Polynomial subtract(Polynomial p) {

Polynomial ans = new X00000000();

// complete this code

return ans;

}

public Polynomial multiply(Polynomial p) {

Polynomial ans = new X00000000();

// complete this code

return ans;

}

public Polynomial divide(Polynomial p) throws Exception {

Polynomial ans = new X00000000();

// complete this code

return ans;

}

public Polynomial remainder(Polynomial p) throws Exception {

Polynomial ans = new X00000000();

// complete this code

return ans;

}

}