Programming does not always happen smoothly, sometimes a lot of patience, devotion and perseverance are required to solve programming problems and stumbling blocks on your way of creating a new programming solution.While developing an application you might come across a number of programming questions the answers to which are not easy to be found. To spare yourself the trouble, submit your programming questions here and you will get programming answers within the shortest time period.

Ask Your question

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search & Filtering

Add two polynomials

Given two polynomials A and B, write a program that adds the given two polynomials A and B


Print the addition of polynomials A and B.

If the degree of polynomial is zero and the constant term is also zero, then just print 0 to represent the polynomial.

For term Cix^Pi, if the coefficient of the term Ci is 1, simply print x^Pi instead of 1x^Pi.Explanation


We can use dictionaries to maintain polynomial coeffients and powers.

Test Case 1:-



0 -20

1 23

2 30

3 19

4 6

5 17


0 -100

5 -89

6 -20

7 -1

1 20

2 4

3 99

4 -45

8 12


12x^8 - x^7 - 20x^6 - 72x^5 - 39x^4 + 118x^3 + 34x^2 + 43x - 120

Note :- Need Space between - and + operators

Test Case 2:-



0 5

1 0

2 10

3 6


0 1

1 2

2 4

Output :-

6x^3 + 14x^2 + 2x + 6

Note:- Need Space between - and + operators

Test Case 3:-



0 -2

3 6

4 7

1 -3

2 -1


0 1

1 2

2 -4

3 3

4 5


12x^4 + 9x^3 - 5x^2 - x - 1

Note:- Need Space between - and + operators

We need all test cases can be came when code was run

Code a program to get the number of students and the group size from the user. Calculate and display the number of groups that must be used to divide the students in the given group size. The last group would possibly not be filled. Display also the number of students in the last group.  


Functions to code and use: 

  • CalcNumberGroups. This function must get the number of students and the group size via parameters. It must calculate and return the number of groups (integer) that would be used. 
  • CalcLastGroupSize.  This function must get the number of students and the group size via parameters. It must calculate and return number of students (integer) in the last group.


If there are 23 students and they must be divided into groups of 6, then there will be 4 groups. The last group will have 5 members.

the logical structure in which one instruction occurs after another with no branching in java

Create a class named DogCare. Include fields for a dog’s data (using Dog class from question 1), the date (using Date class from question 4), the time (using Time class 

The following code is supposed to display the positive even numbers less than 12. That is, it will output the numbers 2, 4, 6, 8 and 10. However, there is a logical error in the code. Explain what the output of the code below will be. Then write a small program including the code below and make the necessary changes to fix the code so that it displays what it is intended to display. Ensure that your program works correctly. Only submit the program, not the output. Hint: Use variable diagrams to trace the program to help you find the logical error. int x = 1; while (x != 12) { cout << x << endl; x = x + 2; } 

A bookshop gives discount to customers as follows:  Students get 10% discount,  Book dealers get 12% discount and  Pensioners get 15% discount.  All other customers get 10% discount only if their total purchases are more than R200. You are requested to write two versions of a program that calculates and displays the final amount that is due, after discount. (i) The first version of the program uses a switch statement to implement the above program. (ii) The second version of the program uses nested-if statements. Hint: Use the following variables: float amount; // the amount due before discount char customerType; // the type of customer: 'S' (student) or // 'D' (dealer) or 'P' (pensioner) or // 'O'(other) float discount, finalAmount; 

Include the for loop below in a small program and complete the program. The loop should execute 10 times. Do not change the for loop below. Compile and run your program to see for yourself that it works. You do not have to submit this program and output. for (int i = 1; i <= n; i++) cout << i * i; Now convert the for loop into a while loop and add any variable initialisations that you think are necessary. Compile and run your program and submit only the program containing the while loop and its output.

The Computer Science Department follows certain criteria when a student learns to program. A number of programming exercises must be worked through. To proceed to the next exercise a student has to obtain a mark of 50% or more and must have completed 5 or more program runs. You are requested to write a program to validate if a student can proceed to the next program. Your program should have the following structure:  Declare two integer variables programsDone and result.  Validate the data captured for the two variables using a while loop.  The loop should be repeated until the value of result is greater than or equal to 50 and the value of programsDone is greater than or equal to 5. 20  Display a message like "Good! You can now proceed to the next exercise"

You are requested to write a very simple calculator. Your calculator should be able to handle the five basic mathematic operations – add, subtract, multiply, divide and modulus – on two input values. Your program should have the following structure:  Ask the user to enter two float variables named var1 and var2  Ask the user to enter a character variable named operation to represent the operation to be performed on the two variables.  Perform the appropriate operation by using if-statements  The output must be given in fixed-point notation with two digits after the decimal point. A typical run is displayed below: Please enter the first float value: 35.6 Please enter the second value: 24.12 Please enter the operation required : + The sum of 35.6 and 24.12 is 59.72 

Find a good cookbook. Read the instructions for your favourite dish. Write a program to display the recipe on the screen but with a difference. The quantity of each ingredient must be multiplied by a value entered from the keyboard. For example, if the recipe needs 2 cups of flour the output displayed will be something like this Please enter the factor to multiply the ingredients with : 4 Recipe name Ingredients // other ingredients 8 cups flour Method The program has the following structure:  Declare an int variable named mFactor to store the value with which the quantity of each ingredient must be multiplied.  The program must make use of a cin statement to input a value from the keyboard and store it in mFactor

New on Blog