Answer:
static int checkSymbol(char ch)
{
switch (ch)
{
case '+':
case '-':
return 1;
case '*':
case '/':
return 2;
case '^':
return 3;
}
return -1;
}
static String convertInfixToPostfix(String expression)
{
String calculation = new String("");
Stack<Character> operands = new Stack<>();
Stack<Character> operators = new Stack<>();
for (int i = 0; i<expression.length(); ++i)
{
char c = expression.charAt(i);
if (Character.isLetterOrDigit(c))
operands.push(c);
else if (c == '(')
operators.push(c);
else if (c == ')')
{
while (!operators.isEmpty() && operators.peek() != '(')
operands.push(operators.pop());
if (!operators.isEmpty() && operators.peek() != '(')
return NULL;
else
operators.pop();
}
else
{
while (!operators.isEmpty() && checkSymbol(c) <= checkSymbol(operators.peek()))
operands.push(operators.pop());
operators.push(c);
}
}
while (!operators.isEmpty())
operands.push(operators.pop());
while (!operands.isEmpty())
calculation+=operands.pop();
calculation=calculation.reverse();
return calculation;
}
Explanation:
- Create the checkSymbol function to see what symbol is being passed to the stack.
- Create the convertInfixToPostfix function that keeps track of the operands and the operators stack.
- Use conditional statements to check whether the character being passed is a letter, digit, symbol or a bracket.
- While the operators is not empty, keep pushing the character to the operators stack.
- At last reverse and return the calculation which has all the results.
Answer: C5₁₆ ⇔ 11000101₂ ⇔ 197⏨
Explanation: 11000101 is a binary number
it's equivalent decimal number is
1x2⁷+ 1x2⁶+0x2⁵ + 0x2⁴+0x2³+1x2²+0x2¹+1x2⁰ = 128+64+4+1 = 197
Hexadecimal system has equivalents in decimal system
0 ⇔0
1 ⇔ 1
2 ⇔ 2
3 ⇔ 3
4 ⇔ 4
5 ⇔ 5
6 ⇔ 6
7 ⇔ 7
8 ⇔ 8
9 ⇔ 9
10 ⇔A
11 ⇔B
12 ⇔C
13 ⇔D
14 ⇔E
15 ⇔F
197 ⇔??
To convert this decimal number in a hexadecimal number we have to divide it by 16
197/16
12,...
the quotient without the decimal part is multiplied by 16 and subtracted from the number
12x16 = 192
197-192 = 5
Then this number can be expressed as 12x16¹ + 5x16⁰ = 192 + 5 = 197
But in the hexadecimal system there are not digits > 9 , so 12 ⇔ C
197⏨ = Cx16¹ + 5x16⁰ = C5₁₆
Answer: C5₁₆ ⇔ 11000101₂ ⇔ 197⏨
Isamember = false;
for( k = 0; k < nmembers; k++ )
{
if( memberid == currentmembers[ k ] )
{
isamember = true;
break; // your class may not be up to this, just delete it
}
}
Answer:
Positive space refers to the subject or areas of interest in an artwork, such as a person's face or figure in a portrait, the objects in a still life painting, or the trees in a landscape painting. Negative space is the background or the area that surrounds the subject of the work.
Explanation:
- The emptiness around and between the shapes or forms are called the negative spaces or ground. We often call it the background but it is more than that.