Hi it's the java stack to convert from infix to postfix If I want to fix...

Hi it's the java stack to convert from infix to postfix

If I want to fix this code to calculate each numbers not just displaying the numbers what should I do?

Would you help me to fix the result?

import java.util.Stack;
import java.util.Scanner;
class Main
{
//Function to return precedence
static int Prec(char ch)
{
switch (ch)
{
case '+':
case '-':
return 1;

case '*':
case '/':
return 2;

case '^':
return 3;
}
return -1;
}
static String infixToPostfix(String exp)
{
// initializing empty String for result
String result = new String("");
Stack<Character> stack = new Stack<>();
int i=0;
int len=exp.length();
for ( i = 0; i<len; ++i)
{
char c = exp.charAt(i);
if (Character.isLetterOrDigit(c))
result =result+ c;
else if (c == '(')
stack.push(c);
else if (c == ')')
{
while (!stack.isEmpty() && stack.peek() != '(')
result =result+ stack.pop();
if (!stack.isEmpty() && stack.peek() != '(')
return "Invalid Expression";   
else
stack.pop();
}
else
{
//for operators
while (!stack.isEmpty() && Prec(c) <= Prec(stack.peek()))
result =result+ stack.pop();
stack.push(c);
}
}
while (!stack.isEmpty())
result =result+ stack.pop();

return result;
}
public static void main(String[] args)
{
String exp = "(5+8)*(7-3)";
String exp2="6+7*(3+9)/2";
System.out.println("Infix "+exp);
System.out.println("Postfix "+infixToPostfix(exp));
System.out.println("Infix "+exp2);
System.out.println("Postfix "+infixToPostfix(exp2));
}
}

In: Computer Science

Real Shocks and the ‘Keynesian Cross’ Suppose the economy of Canada has reached the long-run equilibrium...

Real Shocks and the ‘Keynesian Cross’

Suppose the economy of Canada has reached the long-run equilibrium (i.e. full employment) and assume that the function of exports and imports are as follows:

(1) EX =α0 +α1q+α2(Y∗ −T∗)

(2) IMP =β0 −β1q+β2(Y −T)

where q is the real exchange rate between Canadian and US goods, Y − T is the Canadian disposable income, Y ∗ − T ∗ is the US disposable income, and the α’s and the β’s are positive parameters.

Assume that Prime Minister Trudeau decides to implements a temporary policy that convinces Canadians to buy less imported goods at any given real exchange rate and any given level of disposable income. In particular, assume that this policy lowers β0 in the import function shown above.

Explain how this temporary shock affects the level of output, consumption, investment, government expenditure, the nominal interest rate, the nominal and real exchange rates, and the level of prices in the short run. Use the AA-DD model to answer this question and do not forget to use a diagram to support your answer.

In: Economics

JAVA Implement and test the following static recursive methods. 1) DigitCount – find the sum of...

JAVA

Implement and test the following static recursive methods.

1) DigitCount – find the sum of the digits in an integer digitCount(12345) would be 5

2) Power2 - Efficiently compute exponentiation for non-negative exponents by the following recursive algorithm:

bx = 1 if x == 0

bx = (b(x/2))2 if x is even bx = b * (b(x-1)) if x is odd

3) Write a recursive method isBackwards that has two String parameters and returns true if the two Strings have the same sequence of characters but in the opposite order (ignoring white space and capitalization), and returns false otherwise. The method should throw an IllegalArgumentException if either String is null.

Test this method with following examples, isBackwards("Fried", "deirf") -> true isBackwards("Sit", "Toes") -> false isBackwards("", "") -> true

isBackwards("I madam", "mad am I") -> true

In: Computer Science

Evaluate the difference between the primary market and the secondary market.      Explain how financial intermediaries channel...

  1. Evaluate the difference between the primary market and the secondary market.

     Explain how financial intermediaries channel household savings into financial     investment. (300 words)

thank you

In: Finance

Using the following text string: axcbramneltodaydy Search for the following pattern: 'today' Specify whether or not...

Using the following text string: axcbramneltodaydy

Search for the following pattern: 'today' Specify whether or not you found the pattern. The minimum requirement is to use the string STL, the brute force method and hard code both the text and the pattern.

For extra credit, you can add any of the following:

1. Do not use the string STL.

2. Allow me to enter both the text string and the pattern, including spaces. You can designate a special end-of-text character for me to include.

3. Use the Boyer-Moore algorithm instead of brute force.

4. Identify the location where the pattern was found within the text.

5. Allow for the possibility that the pattern can appear more than once in the text and identify all of the locations where the pattern was found.

In: Computer Science

simple staining lab 3 simple stain experiment

simple staining lab 3 simple stain experiment

In: Biology

A student decides to move a box of books into her dormitory room by pulling on...

A student decides to move a box of books into her dormitory room by pulling on a rope attached to the box. She pulls with a force of 83.2 N at an angle of 28.0° above the horizontal. The box has a mass of 20.0 kg, and the coefficient of kinetic friction between box and floor is 0.300. (Indicate the direction with the sign of your answer.)

(a) Find the acceleration of the box. (Assume that the +x-axis is to the right and the +y-axis is up along the page.)

magnitude     m/s2
direction     ° counterclockwise from the +x-axis



(b) The student now starts moving the box up a 10.0° incline, keeping her 83.2 N force directed at 28.0° above the line of the incline. If the coefficient of friction is unchanged, what is the new acceleration of the box? (Assume that the +x-axis is along the incline and the +y-axis is upwards and perpendicular to the incline.)

magnitude     m/s2
direction     ° counterclockwise from the incline

PLEASE EXPLAIN STEPS

In: Physics

Questions regarding the lab: Spectrophotometric Determination of Caffeine in a Soft Drink 1)How are the absorption...

Questions regarding the lab: Spectrophotometric Determination of Caffeine in a Soft Drink

1)How are the absorption spectra of atoms and molecules the same, and how are they different?

2)Beer’s law, A=e b c forms the basis of a calibration curve. It clearly shows that there is a theoretically linear relationship between absorbance and concentration under constant conditions of analyte absorptivity (e) and path length (b). However, it is important for an analyst to be aware that there are limitations analyte concentration range under which there truly is a linear relationship between absorbance and concentration. Under what conditions of concentration does the linear relationship break down?

3)Caffeine is not fluorescent. However, just for argument’s sake imagine that it was fluorescent. Would the wavelength of maximum fluorescence be shorter, longer, or equal to the wavelength of maximum absorbance? Why?

4)Why was it necessary to remove CO2 before the analysis?

In: Chemistry

Hi, how can I create a random guessing game in C++ with 2 players. I got...

Hi, how can I create a random guessing game in C++ with 2 players. I got some of the code but not working properly.

//Guess my number game
#include <iostream>
#include <ctime>
using namespace std;

int main()

{
   int seed = time(0);
   srand(seed);
   int randomNumber = rand() % 100 + 1;
   int userInput1, userInput2;
   int counter = 0;

   cout << "Welcome to Guess my Number" << endl;

   do
   {
       cout << "PLAYER1 enter a number: ";
       cin >> userInput1;
       cout << "PLAYER2 enter a number: ";
       cin >> userInput2;

       if (userInput1 == randomNumber)
           cout << "Congratulations you WON!" << endl;

       else if (userInput1 > randomNumber)
           cout << "Winning number is lower." << endl;

       else
           cout << "Winning number is higher." << endl;

       counter++;
       cout << endl;

   } while (userInput1 != randomNumber);

   cout << "The winning number was " << randomNumber << endl;
   cout << "Number of attempts. " << counter << endl;


   system("pause");
   return 0;
}

In: Computer Science

A long solenoid has 110 turns/cm and carries current i. An electron moves within the solenoid...

A long solenoid has 110 turns/cm and carries current i. An electron moves within the solenoid in a circle of radius 2.50 cm perpendicular to the solenoid axis. The speed of the electron is 0.040 c (c = speed of light). Find the current i in the solenoid.

In: Physics

Use the function from Q1 to find the sum of ints,n, from 1 to 2500, inclusive,...

Use the function from Q1 to find the sum of ints,n, from 1 to 2500,

inclusive, that satisfy the following boolean:

     ((n div by 11) and ( n is div by 13) ) or (n is div by 61)

Print out the sum with a labelled print:

The sum of qualifying ints, n, 1 <= n <= 2500, is ___________.

Hint: Remember that you can use a for loop to traverse a list.

For example:

L = [23,37,41,53,61]:

for n in L:

    print(n, end = ' ')

23 37 41 53 61

>>>

You can do this even more easily if you use the BIF sum, which returns the sum

of the numbers in a list

L1 = [2,7,13]

Sum = sum(L1)

print(Sum)

22

Write code to find the product of every 19th qualifying int (19th, 38th,...) from Q2, then

print out a labelled print:

The product of every 19th qualifying int is ____________

Then write code to find the sum of every 2nd qualifying int (2nd,4th,...) from Q2, then

print out a labelled print:

The sum of every 2nd qualifying int is ______________

Hint: Set up a counter and initialize the counter to zero.

Increase the counter as the ints from the list returned from Q2 are traversed.

Do not use indices - just use what has been taught. You can tell from the

counter what qualified int you are currently on. Knowing this, you can determine if

you are on a 2nd or a 19th qualifying int.

What is the largest int times the sum that is less than or equal to the product?

Print this out with a labelled print statement:

The largest int times the sum that is less that or equal to the product is _____________.

In: Computer Science

Normative Economics (Efficiency vs, Equity) there are two types of economic Efifficence Vs Equity why it...

Normative Economics (Efficiency vs, Equity)

there are two types of economic Efifficence Vs Equity why it is more important than the efficiency goal than equity?

why it is more important than the equity goals than efficient too ?

In: Economics

Any amount received or accrued by a taxpayer from an educational policy, which has been expended...

Any amount received or accrued by a taxpayer from an educational policy, which has
been expended for providing education or training at a recognised educational
institution of a child or stepchild is exempt according to Section 16(1)(ab).
On the last day of the year of assessment, the child or stepchild is not required to be? a) Not over the age of 26 years b) Living with the parents c) All of the above d) None of the above

6. In the case Lategan v CIR (CPD 1926), the word accrued was held to mean: a) ‘’accrued to” b) “to which he has become entitled” c) “received on his own behalf” d) “received for his benefit”

7. Jackson Samuel is a 27-year old writer who is a Namibian resident. He paid a royalty of
N$ 100 000 by Crazy Films for the right to use one of his copyrighted books in the next
film.
The royalty payment received will be included in Jackson’s Gross Income for the year. a) False b) True

8. What is the tax treatment of the royalties received? a) Included in Gross Income only b) Included in Gross Income and then Exempt c) Not Taxable d) Specifically deductible


Page 12 of 25


9. Mrs Martha retires and is paid a pension retirement of N$10 000 per month from a fund
in Botswana. She has spent the last 9 years of her 16 years of service in Namibia. What
is the amount deemed to be Namibian source income for the specific year of
assessment? a) N$ 5 625 b) N$ 90 000 c) N$ 67 500 d) N$ 17 778

10. The onus is on the tax payer to prove that certain amounts are of a capital nature. If
there is a dispute and the case goes to court, the court will take into account certain
factors in reaching a decision. Which of the following is not a factor to consider? a) The intention of the taxpayer b) The objective of the taxpayer c) The period the assets are held d) The type of asset held

11. Ms Charon has been working in Namibia for the past 5 months. She is an employee of a
company operating in Britain and was sent to Namibia to supervise the opening of the
company’s new branch in Oshakati. The salary that she has earned for the five months is
taxable in Namibia. a) True b) False

12. Sara Maneti has recently retired after a long career in the mining industry of Namibia.
Upon retirement, she received N$ 250 000 lump sum from her employer. She used N$
180 000 to purchase an annuity from a foreign insurance company.


Page 13 of 25

What amount should the lump sum from employer be in order to be taxable in three
equal instalments, starting in the year of payment and two following years? a) Over N$ 500 000 b) Over N$ 300 000 c) Over N$ 200 000 d) Under N$ 300 000

13. The following is a requirement for the lump sum from employer exemption. a) The person attained the age of fifty b) Termination of service due to criminal conviction c) Termination of service due to end of employment contract d) The minister is satisfied that the person is retrenched

14. An employee receives housing benefits provided in terms of approved housing schemes.
Where the remuneration of the employee does not exceed N$ 15 000 per annum, the
housing benefit is exempted as follows: a) One third of the benefit is exempt b) Benefit is fully exempted c) Benefit does not qualify for exemption d) Two third of the benefit is exempt

15. Where an employee’s remuneration exceeds N$ 15 000 per annum but not N$ 30 000
the housing benefit is reduced by Y% in the formula
? = 100−
? 150
Where X in the formula represents: a) Remuneration less housing benefit b) Employee’s remuneration c) Amount of housing benefit d) Excess of employee’s remuneration


Page 14 of 25

16. According to Section 16(1)(q), alimony refers to any amount … a) Received by a spouse married in community of property b) Received by a spouse married out of community of property c) Received by a spouse of behalf of a child d) Received from a former spouse after divorce settlement

17. Which of the following is not a characteristic of an annuity? a) Repetitive cash payment b) Annual payment c) Chargeable against a person d) Continuous payment

18. 65-year old John Smith retired in January 2020. He received N$ 200 000 lump sum from
his employer. Some of his receipts for the year also included N$ 8 000 withdrawal
benefit from a pension fund, N$ 300 000 retirement benefit from a provident fund and
N$ 2 000 war pension. After retirement, John continued running the business that he
had started a few years ago. During the year, the business earned N$ 90 000 in profits.
Which one of the above does not constitute John’s income for the year of assessment
ending 29 February 2020? a) Business profits b) Withdrawal benefit from pension fund c) War pension d) Retirement benefit from provident fund

19. If John had deposited N$ 100 000 of his lump sum into a NamPost saving account and
earned interest on the savings account, the interest received by John would not be
taxable. a) False b) True


Page 15 of 25


20. Specifically included in John’s Gross Income should be any amount, excluding all
voluntary award, received or accrued in respect of services rendered or to be rendered. a) True b) False

21. Lucas Josephat is a Namibian resident employed as a salesperson at Build-In Wholesaler
in Ongwediva. During the 2019 year of assessment he won a prize for being its most
productive salesperson of the year. The prize was valued at N$ 20 000 (this amount was
also the cost of this prize to his employer). Why will the prize received not be included in
his gross income for the year of assessment ending 2019? a) Not arising out of an operation of business b) Closely connected with his employment c) Constitute a receipt of a capital nature d) Benefit of his employment

22. Desmond Xaweb 68-year old pensioner owns three tuck shops in Kunene Region. He has
lived his whole life in Namibia and has never left the country. Desmond is also the
owner of a house located a few kilometres outside Okahandja. After his death in January
this year, Desmond’s grandson, Dion, inherited the house. The house was valued at N$ 2
500 000 by an independent real estate evaluator. After facing cash flow problems, Dion
decided to sell the house for N$ 2 000 000 during the same year. Will the proceeds from
the sale of house by Dion be considered of income nature? a) True b) False   



Page 16 of 25

23. Under which circumstances will the receipts from the house sold by Dion be considered
of capital nature? a) If he had not inherited the property b) If he had a scheme of selling the property for profit c) If his intention was that of speculation or investment d) If he did not enter into an extensive advertising campaign to sell it

24. Lisa Kutako, a property developer living and trading in Pretoria, inherited a block of flats
in Windhoek on 3 March 2019, valued at N$ 8 000 000, from aunt who lived in Outjo.
Since Lisa was at that time selling two other blocks of flats under sectional title, she
immediately applied for sectional title rights on her inherited property. By 29 February
2020, she had sold all the flats in her inherited property for N$ 9 000 000.
Where will Lisa be taxed on the receipts from the flats sold? a) South Africa b) Namibia c) All of the above d) None of the above

25. All exemptions are first included in gross income and thereafter deducted. Funds of
certain associations and enterprises are fully exempted from paying income tax due to
their nature of operation. Which of the following Namibian associations do not qualify
for such an exemption? a) Namibia Stock Exchange b) Teachers’ Union of Namibia c) Hope Village d) GIPF


Page 17 of 25

26. After a few years of learning about the tax effects of different investment options,
Martha Nami, 34-year old woman married in community of property, decided to buy
treasury bills. Based on their tax implications, why did Martha decide to purchase them? a) All expenses incurred are deductible b) Interest earned does not constitute of income c) All of the above d) None of the above

27. During the 2019 year of assessment, Gina Garises earned N$ 75 000 taxable income.
What is the applicable normal tax rate for her? a) 29% of the amount by which the taxable income exceeds N$ 50 000 b) 25% of the amount by which the taxable income exceeds N$ 50 000 c) 29% of the amount by which the taxable income exceeds N$ 40 000 d) 27% of the amount by which the taxable income exceeds N$ 40 000

28. The newly appointed non-executive director of Metro Small Company, Shawn Wilson, is
a Namibian resident who lives and works in Outapi. Upon his appointed to the office, he
receives an annual housing allowance of N$ 20 000 and a travel allowance of N$ 15 000
along with the right to use of the company car that has a market value of N$ 178 000.
Which of the above are fringe benefits? a) The housing and travel allowances b) The right to use the company car c) None of the above mentioned benefits d) Only the travel allowance and the right to use the company car

29. Goldie-Locks is a licenced gold producer headquartered in Toronto, Canada. Founded in
2010, today, Goldie-Locks has three operating gold mines located in various countries
including the Philippines, Namibia, and Congo. In 2020, Goldie-Locks forecasts
consolidated gold production of between 1,000,000 and 1,055,000 ounces.


Page 18 of 25

In which country will the income of Goldie-Locks be taxed? a) Philippines b) Congo c) Canada d) All of the above

30. If Goldie-Locks is to be taxed in Namibia, what will be the applicable flat tax rate for
such a mining company? a) 37.5% b) 35 % c) 50.% d) 18.%

31. DiaNam is a Namibian owned licensed diamond company that performs land-based
prospecting (exploration), mining and rehabilitation operations in the southwest coast
of the country. What is the applicable tax flat rate for DiaNam? a) 37.5% b) 35 % c) 50.% d) 18.%

32. Mate-Rial is a textile manufacturing company that was registered at the Ministry of
Trade and Industry in October 2013. With a factory located in Gobabis, the company
employs over 300 local residents. During the 2019 year of assessment, hired five
Malaysian textile specialist to assist it with the production of a new synthetic leather
fabric in order to abide to its vegan cruelty-free policy.
What is current the applicable flat rate for manufacturing company in Namibia? a) 37.5% b) 34 % c) 50.% d) 18.%


Page 19 of 25

33. Grace Wandje is a local business woman who lives in Khorixas. She is a teacher at a
primary school in her area and owns property as well as other small businesses. If her
income for the year of assessment ended 29 February 2020 is as follows; what will be
her gross income for the year ended 29 February 2020?
Salary 80 000
Rent received 20 000
Dividends received 4 000
Bet win on result of soccer match 1 000
Profit on sale of shares held as trading stock 4 000
Loss of profits insurance claim 2 000
Interest received 2 000
Restraint of trade payment 8 000
N$125 000
a) N$ 112 000 b) N$ 125 000 c) N$ 117 000 d) N$ 122 000

In: Accounting

Write a script that accepts a single character argument (command line parameter), then checks to see...

Write a script that accepts a single character argument (command line parameter), then checks to see if the argument is an upper- or lower-case letter. (You do not have to do any error checking. Just assume that the user will enter a single character.) Hint: use grep to search for a member of the character class [a-z]. Then use the exit code (in an if statement) to see if grep was successful and write the proper response. If the argument is a letter, print (display to screen) “You entered a letter.” If the argument is not a letter, print “You did not enter a letter.”

In: Computer Science

Answer the following questions completely. Describe some of the differences between tariffs and quotas. What are...

Answer the following questions completely.

Describe some of the differences between tariffs and quotas.

What are the intent and impact of domestic content requirements?

Is a tariff-rate quota a two-tier tariff? Why?

What is an OMA?

In: Economics