Programming & Computer Science Answers

C++ 9913
Python 5288
Java | JSP | JSF 3611
C 1680
C# 1362
Computer Networks 989
Algorithms 652
Databases | SQL | Oracle | MS Access 641
HTML/JavaScript Web Application 588
Other 537
Visual Basic 358
Assembler 209
Software Engineering 202
AJAX | JavaScript | HTML | PHP 166
MatLAB 150
MatLAB | Mathematica | MathCAD | Maple 124
Action Script | Flash | Flex | ColdFusion 112
UNIX/Linux Programming 89
Web Development 73
Excel 36
ASP | ASP.NET 23
Delphi | Pascal 21
Perl 16
Prolog 9
Functional Programming 9
MathCAD 5
Wolfram Mathematica 4
WPF 4
Ruby | Ruby on Rails 3
NodeJS Web Application 2

Questions answered by Experts: 26 876

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

Just post is a new courier service company which services all provinces in the South Africa. They charge 

their customers based on the weight of the parcel as indicated in the table below. However, if kilograms 

are above 50, the cost is charged according to the number of hours it took to deliver. Although the time 

is entered in minutes but they are charged R95.00 per hour. Clients may also add some extras to the 

delivery such as insurance which is charged 8.5% and priority is charged at 5% of the charge.


Distance Weight Cost (R)

Local Under 5 kg R125.00

Local 5 kg up to 20 kg R175.00

Local Over 20 Kg R250.00

Long Under 5 kg R390.00

Long 5 kg up to 20 kg R450.00

Write a program that will assist with calculating the postage amount.

2.1 Create a C++ source file called Postage and save it in a file called Postage.cpp. 

2.2 Create the following functions: 

 



Just post is a new courier service company which services all provinces in the South Africa. They charge 

their customers based on the weight of the parcel as indicated in the table below. However, if kilograms 

are above 50, the cost is charged according to the number of hours it took to deliver. Although the time 

is entered in minutes but they are charged R95.00 per hour. Clients may also add some extras to the 

delivery such as insurance which is charged 8.5% and priority is charged at 5% of the charge.


Distance Weight Cost (R)

Local Under 5 kg R125.00

Local 5 kg up to 20 kg R175.00

Local Over 20 Kg R250.00

Long Under 5 kg R390.00

Long 5 kg up to 20 kg R450.00

Write a program that will assist with calculating the postage amount.

2.1 Create a C++ source file called Postage and save it in a file called Postage.cpp. 

2.2 Create the following functions: 

 



State whether each of the following is true or false. Explain why.

a. The default case is required in the switch selection statement.

b. The break statement is required in the last case of a switch selection statement.

c. The expression ( (x > y) && (a < b ) ) is true if either x > y is true or a < b is true.

d. An expression containing the || operator is true if either or both of its operands are true.

e. The comma (,) formatting flag in a format specifier (e.g., %,20.2f) indicates that a value should be output with a thousands separator.

f. To test for a range of values in a switch statement, use a hyphen () between the start and end values of the range in a case label.

g. Listing cases consecutively with no statements between them enables the cases to perform the same set of statements.


State whether each of the following is true or false. If false, explain why.

a. An algorithm is a procedure for solving a problem in terms of the actions to execute and the order in which these actions execute.

b. A set of statements contained within a pair of parentheses is called a block.

c. A selection statement specifies that an action is to be repeated while some condition remains true.

d. A nested control statement appears in the body of another control statement.

e. Java provides the arithmetic compound assignment operators +=, -=, *=, /= and %= for abbreviating assignment expressions.

f. The primitive types (boolean, char, byte, short, int, long, float and double) are portable across only Windows platforms.

g. Specifying the order in which statements (actions) execute in a program is called program control.

h. The unary cast operator (double) creates a temporary integer copy of its operand.

i. Instance variables of type boolean are given the value TRue by default.

j. Pseudocode helps a programmer think out a program before attempting to write it in a programming language.

 

Write four different Java statements that each add 1 to integer variable x.


Suppose you had reduced a 32-variable Boolean expression using Quine–McCluskey algorithm to a 12-variable expression. For the generated simplified expression, you are required to implement it into a digital logic circuit. You can only use Programmable Array Logic (PAL) or Programmable Logic Array (PLA) devices.

Assume that we had selected a Programmable Array Logic (PAL) and a Programmable Logic Array (PLA) for you to choose between.

  1. Using TICPAL22V10Z-25C (Programmable Array Logic)
  2. Using PLUS173–10 (Programmable Logic Array).

Your selections among stated PLA and PAL must consider the following constraints:

  • Complexity
  • Flexibility
  • Speed
  • Functionality
  • Cost

Abhinav and Anjali are playing the Tic-Tac-Toe game. Tic-Tac-Toe is a game played on a grid that's three squares by three squares. Abhinav is O, and Anjali is X. Players take turns putting their marks in empty squares. The first player to get 3 of her marks in a diagonal or horizontal, or vertical row is the winner. When all nine squares are complete, the game is over. If no player has three marks in a row, the game ends in a tie. Write a program to decide the winner in the Tic-Tac-Toe game.Input


The input will be three lines contain O's and X's separated by space.Output


The output should be a single line containing either "Abhinav Wins" or "Anjali Wins" or "Tie".Explanation


For example, if the input is

O X O
O X X
O O X 

as three of O's are in vertical row print "Abhinav Wins".


Write a program to create a menu-driven calculator that performs basic arithmetic operations (+, -, *, /, and %).Input


The input will be a single line containing two integers and operator(+, -, *, /, and %) similar to 3 + 5.Output


If the given operator is "+", print the sum of two numbers.

If the given operator is "-", print the result of the subtraction of the two numbers.

If the given operator is "*", print the multiplication of the two numbers.

If the given operator is "/", print the result of the division of the two numbers.

If the given operator is "%", print the result of the modulus operation of the two numbers.Explanation


For example, if the given operator is "+" and the two numbers are 3 and 5. As it is an addition operator, your code should print the sum of the given two numbers (3 + 5), which is 8.

Similarly, if the given operator is "*" and the two numbers are 2 and 5.

As it is a multiplication operator, your code should print the result of the multiplication of the given two numbers (2 * 5), which is 10.

Similarly, if the given operator is "-" and the two numbers are 10 and 9.

As it is a subtraction operator, your code should print the result of the subtraction of the given two numbers (10 - 9), which is 1.


Given a sentence S, write a program to print the frequency of each word in S, where words are sorted in alphabetical order.Input


The input will be a single line containing a string S.Output


The output contains multiple lines, with each line containing a word and frequency of each word in the given string separated by ": ", where words are sorted in alphabetical order.Explanation


For example, if the given sentence is "Hello world, welcome to python world", the output should be

Hello: 1

python: 1

to: 1

welcome: 1

world: 2


Given polynomial, write a program that prints polynomial in Cix^Pi + Ci-1x^Pi-1 + .... + C1x + C0 format.Input


The first line contains a single integer N.

Next N lines contain two integers Pi, Ci separated with space, where Pi denotes power and Ci denotes coefficient of Pi.Output


Print the polynomial in the format Cix^Pi + Ci-1x^Pi-1 + .... + C1x + C0, where Pi's are powers in decreasing order, Ci is coefficient, and C0 is constant. There will be space before and after the plus or minus sign.

If the coefficient is zero, then don't print the term.

If the term with the highest degree is negative, the term should represent -Cix^Pi.

For the term where power is 1, represent it as C1x instead of C1x^1.

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

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


If N = 4

For power 0, the coefficient is 5

For power 1, the coefficient is 0

For power 2, the coefficient is 10

For power 3, the coefficient is 6.

Then polynomial represents "6x^3 + 10x^2 + 5"


You are given a square matrix A of dimensions NxN. You need to apply the below given 3 operations on the matrix A.


Rotation: It is represented as R S where S is an integer in {90, 180, 270, 360, 450, ...} which denotes the number of degrees to rotate. You need to rotate the matrix A by angle S in the clockwise direction. The angle of rotation(S) will always be in multiples of 90 degrees.


Update: It is represented as U X Y Z. In initial matrix A (as given in input), you need to update the element at row index X and column index Y with value Z.

After the update, all the previous rotation operations have to be applied to the updated initial matrix.


Querying: It is represented as Q K L. You need to print the value at row index K and column index L of the matrix A. Input


The first line contains a single integer N.

Next N lines contain N space-separated integers Aij (i - index of the row, j - index of the column).

Next lines contain various operations on the array. Each operation on each line (Beginning either with R, U or Q).

-1 will represent the end of input.Output


For each Query operation print the element present at row index K and colum index L of the matrix in its current state.Explanation


For Input:

2

1 2

3 4

R 90

Q 0 0

Q 0 1

R 90

Q 0 0

U 0 0 6

Q 1 1

-1


Initial Matrix

1 2

3 4


For R 90, clockwise rotation by 90 degrees, the matrix will become

3 1

4 2


For Q 0 0, print the element at row index 0 and column index 0 of A, which is 3.

For Q 0 1, print the element at row index 0 and column index 1 of A, which is 1.


Again for R 90, clockwise rotation by 90 degrees, the matrix will become

4 3

2 1


For Q 0 0, print the element at row index 0 and column index 0 of A, which is 4.


For U 0 0 6, update the value at row index 0 and column index 1 in the initial matrix to 6. So the updated matrix will be,

6 2

3 4

After updating, we need to rotate the matrix by sum of all rotation angles applied till now(i.e. R 90 and R 90 => 90 + 90 => 180 degrees in clockwise direction).

After rotation the matrix will now become

4 3

2 6


Next for Q 1 1, print the element at row index 1 and column index 1 of A, which is 6.

output

3

1

4

6


LATEST TUTORIALS
APPROVED BY CLIENTS