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

Split and Replace

Given three strings

inputString, separator and replaceString as inputs. Write a JS program to split the

inputString with the given separator and replace strings in the resultant array with the replaceString whose length is greater than 7.

Quick Tip

  • You can use the string method split()
  • You can use the array method map()

Input

  • The first line of input contains a string inputString
  • The second line of input contains a string separator
  • The third line of input contains a string replaceString

Output

  • The output should be a single line containing the strings separated by a space

Sample Input 1

JavaScript-is-amazing

-

Programming

Sample Output 1

Programming is amazing

Sample Input 2

The&Lion&King

&

Tiger

Sample Output 2

The Lion King




write a program in c++ which takes two 4 x 4 matrices as input from the user and displays the matrices in tabular form. then ask user to make a choice: 1. press 1 for matrix addition 2. press 2 for matrix subtraction 3. press 3 for matrix multiplication 4. press 4 for matrix transpose use 2d arrays to save matrix values and use functions to perform addition, subtraction, multiplication and transpose. refer below examples to understand the concept of matrix operations.


Weekends

Given two dates D1 and D2, write a program to count the number of Saturdays and Sundays from D1 to D2 (including D1 and D2).

The date in string format is like "8 Feb 2021".Input


The first line of input will contain date D1 in the string format.

The second line of input will contain date D2 in the string format.Output


The output should be a single line containing two integers separated by space.Explanation


For example, if the given dates are "25 Jan 2021" and "14 Feb 2021", the Saturdays and Sundays dates from "25 Jan 2021" to "14 Feb 2021" are

"30 Jan 2021" is a Saturday

"31 Jan 2021" is a Sunday

"6 Feb 2021" is a Saturday

"7 Feb 2021" is a Sunday

"13 Feb 2021" is a Saturday

"14 Feb 2021" is a Sunday

So the output should be

Saturday: 3

Sunday: 3

Sample Input 1

25 Jan 2021

14 Feb 2021

Sample Output 1

Saturday: 3

Sunday: 3



using if ___ else statement and switch case statement for each problem.

-Question 1      

The Last Stop Boutique is having a five-day sale. Each day, starting on Monday, the price will drop 10% of the previous day’s price. For example, if the original price of a product is $20.00, the sale on Monday would be $18.00 (10% less than the original price).

 

On Tuesday the sale price would be $16.20 (10% less than Monday)

On Wednesday - $14.58.

On Thursday - $13.12.

On Friday - $11.81.


Develop a solution that will calculate the price of an item for each of the five days, given the original price. Test the solution for an item costing $10.00.         

 

-Question 2

Make changes in the solution to problem 1 to SET the price at wholesale when the sale price drops below the wholesale price. Test the solution with the following prices:

 

Retail price: $20.00 & $25.00

Wholesale price: $10.00 & $20.00


EXPLAIN IN DETAIL


A network G = (V, E) has 220 nodes. Each node v is labeled by a unique number L(v) between 0 to

220-1. No two nodes have the same label and there is a label for every node.

Two nodes u and v have an undirected edge (u, v) between them if and only if the following is true:

(i)The labels of the nodes L(u) and L(v) differ by a Hamming distance of at most 2 in their

binary representation, and

ii)The magnitude of the difference between the two numbers in the two labels is no

more than 9, i.e. | L(u) – L(v) | < 9. 

Answer all of the following questions:

(a) How many nodes in the graph are unreachable from the node with the label

00000000000000000111?

(b) Is the node 11110000000000000000 reachable from the node 00000000000000001111?

(c) How many edges are present in this graph?

(d) Is this graph bipartite?

(e) How many connected components are present in this graph?


 


Secret Message - 1

Given a string, write a program to mirror the characters of the string in alphabetical order to create a secret message.


Note: Mirroring the characters in alphabetical order replacing the letters 'a' with 'z', 'b' with 'y', ... , 'z' with 'a'. You need to mirror both uppercase and lowercase characters. You can ignore mirroring for all characters that are not letters.


abcdefghijklmzyxwvutsrqpon nopqrstuvwxyzmlkjihgfedcbaInput


The input will be a string in the single line containing spaces and letters (both uppercase and lowercase).Output


For example, if the given input is "python", "p" should replaced with "k", similarly "y" with "b", "t" with "g", "h" with "s", "o" with "l", "n" with "m". So the output should be "kbgslm".

Sample Input 1

python

Sample Output 1

kbgslm

Sample Input 2

Foundations




Prefix Suffix

Write a program to check the overlapping of one string's suffix with the prefix of another string.Input


The first line of the input will contain a string A.

The second line of the input will contain a string B.Output


The output should contain overlapping word if present else print "No overlapping".Explanation


For example, if the given two strings, A and B, are "ramisgood" "goodforall"

The output should be "good" as good overlaps as a suffix of the first string and prefix of next.

Sample Input 1

ramisgood

goodforall

Sample Output 1

good

Sample Input 2

finally

restforall

Sample Output 2

No overlapping




Max Contiguous Subarray

Given a list of integers, write a program to identify the contiguous sub-list that has the largest sum and print the sum. Any non-empty slice of the list with step size 1 can be considered as a contiguous sub-list.Input


The input will contain space-separated integers, denoting the elements of the list.Output


The output should be an integer.Explanation


For example, if the given list is [2, -4, 5, -1, 2, -3], then all the possible contiguous sub-lists will be,

[2]
[2, -4]
[2, -4, 5]
[2, -4, 5, -1]
[2, -4, 5, -1, 2]
[2, -4, 5, -1, 2, -3]
[-4]
[-4, 5]
[-4, 5, -1]
[-4, 5, -1, 2]
[-4, 5, -1, 2, -3]
[5]
[5, -1]
[5, -1, 2]
[5, -1, 2, -3]
[-1]
[-1, 2]
[-1, 2, -3]
[2]
[2, -3]
[-3]

Among the above contiguous sub-lists, the contiguous sub-list [5, -1, 2] has the largest sum which is 6.

Sample Input 1

2 -4 5 -1 2 -3

Sample Output 1

6




Interleave Strings

Given two strings, write a program to merge the given two strings by adding characters in alternating order, starting with the first string. If a string is longer than the other, append the additional characters onto the end of the merged string.Input


The first line of input will contain a string.

The second line of input will contain a string.

The strings may contain special characters, digits and letters.Output


The output should be the merged stringExplanation


For example, if the given strings are "abc" and "pqrs", then alternating characters from each string are merged as "a" from "abc", "p" from "pqr", "b" from "abc" and so on ..., resulting in the merged string "apbqcr".

Sample Input 1

abc

pqr

Sample Output 1

apbqcr

Sample Input 2

abc

pqrst

Sample Output 2

apbqcrst




Add two polynomials

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


Sample Input

4

0 5

1 0

2 10

3 6

3

0 1

1 2

2 4

Sample Output

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


Sample Input

5

0 -2

3 6

4 7

1 -3

2 -1

5

0 1

1 2

2 -4

3 3

4 5

Sample Output

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



Sample Input

5

0 2

1 0

2 1

4 7

3 6

5

2 4

3 3

4 5

0 1

1 0

Sample Output

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


LATEST TUTORIALS
APPROVED BY CLIENTS