int[] counter = new int[10]; 29. Fill in the blank to specify that objects of a
ID: 3721064 • Letter: I
Question
int[] counter = new int[10];
29. Fill in the blank to specify that objects of a class named Purchase can be serialized. There may be more than one word in the blank.
public class __________ {
30. What is the value assigned to answer? Show your work one operator at a time.
int answer;
answer = 6 * (3 + 5) % 7 + 5 / 2;
31. A salesperson earns a commission of 2% on sales up to $10,000, then earns a commission of 5% on any sales over $10,000. Write a sequence of statements to save the salesperson's commission to an integer value named commission, given his or her sales in an integer value named sales. (You may round all commission values down.
Explanation / Answer
29)public class Purchase implements Serializable
30)answer=6*(3+5)%7+5/2;
initially expression in braces will be evaluated so (3+5) will be evaluated and it will be 8
and operators associativity will be from left to right
6*8%7+5/2
so 6*8 will be evaluated and now expression will be
48%7+5/2
after this 5/2 will be evaluated and value will be 2 so expression will be
48%7+2
now 48%7 will be evaluated and it will be 6 now expression will be
6+2=8 so 8 will be stored in answer
31)
int commision;
if(sales<10000)
commision=2;
else if(sales>10000)
commision=5;
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.