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

"use strict";


process.stdin.resume();

process.stdin.setEncoding("utf-8");


let inputString = "";

let currentLine = 0;


process.stdin.on("data", (inputStdin) => {

 inputString += inputStdin;

});


process.stdin.on("end", (_) => {

 inputString = inputString.trim().split("\n").map((str) => str.trim());

 main();

});


function readLine() {

 let input = inputString[currentLine++]; 

 return input === undefined ? undefined : JSON.parse(input);

}


/* Please do not modify anything above this line */

  

 /* Write your code here */ 

  


/* Please do not modify anything below this line */


function main() {

 const principal = readLine();

 const time = readLine();

 const apprPercentage = readLine();


 const finalValue = calculateFinalValueWithAppreciation(principal, time, apprPercentage);


 console.log(finalValue);

}



Final Value with Appreciation

Given principal amount

principal as an input, time period in years time and appreciation percentage apprPercentage as optional inputs, write a JS function to return the final value finalValue with the given appreciation percentage and time period. The default values for time and apprPercentage are 2 and 5 respectively.

Quick Tip

The formula to calculate the final value with appreciation is,

finalValue = principal * (1 + time * appreciation / 100)

Input

  • The first line of input contains a number principal
  • The second line (optional) of input contains a number time
  • The third line (optional) of input contains a number apprPercentage

Output

  • The output should be a single line containing the finalValue


Sample Input 1

1000

2

3


Sample Output 1

1060


Sample Input 2

3000


Sample Output 2

3300.0000000000005



Time Converter

In this assignment, let's build a Time Converter by applying the concepts we learned till now.

Refer to the below image.


https://assets.ccbp.in/frontend/content/dynamic-webapps/time-converter-output.gif


Instructions:

  • The HTML input element for entering the number of hours should have the id hoursInput
  • The HTML input element for entering the number of minutes should have the id minutesInput
  • Add HTML label elements for HTML input elements with ids hoursInput and minutesInput
  • The HTML button element should have the id convertBtn
  • The HTML p element to display the converted time in seconds should have the id timeInSeconds
  • The HTML p element to display the error message should have the id errorMsg

By following the above instructions, achieve the given functionality.

  • When values are entered in HTML input elements with ids hoursInput and minutesInput, the HTML button with id convertBtn is clicked
  • The converted time in seconds should be displayed in the HTML p element with id timeInSeconds
  • The HTML p element with id errorMsg should be empty
  • The HTML p element with id errorMsg should display an error message in the following cases
  • When the HTML input element with id hoursInput is empty and convertBtn is clicked
  • When the HTML input element with id minutesInput is empty and convertBtn is clicked
  • When both the HTML input elements hoursInput and minutesInput are empty and convertBtn is clicked

Quick Tip

  • timeInSeconds = ((hours) *60 + minutes) * 60

Note

  • The values given for the HTML input elements with ids hoursInput and minutesInput should be positive integers.

Resources

Use this Background image:

  • https://assets.ccbp.in/frontend/dynamic-webapps/time-converter-bg.png

CSS Colors used:

Text colors Hex code values used:

#f5f7fa

#000000

#ffffff


CSS Font families used:

  • Open Sans

Write a program to control a set of 10 motors; the motors are operating under load balancing mechanism as

follows:

• Motors operate in pairs as follows: 1,10 then 2, 9 then 3,8 then 4,7 then 5,6 then repeat.

• The operating duration for each pair is 10,000 milliseconds.

• After each operating cycle, all motors must be OFF for 10,000 milliseconds then a new cycle starts.

• The operating sequence is running 24/7.


String Starts or Ends with given String

Given an array

stringsArray of strings, and startString, endString as inputs, write a JS program to filter the strings in stringsArray starting with startString or ending with endString.

Quick Tip

You can use the array method filter() and logical operator OR ( || ).


Input

  • The first line of input contains a string stringsArray
  • The second line of input contains a string startString
  • The third line of input contains a number endString

Output

  • The output should be a single line containing an array of filtered strings


Sample Input 1

['teacher', 'friend', 'cricket', 'farmer', 'rose', 'talent', 'trainer']

t

r


Sample Output 1

[ 'teacher', 'farmer', 'talent', 'trainer' ]


Sample Input 1

['dream', 'player', 'read', 'write', 'trend']

p

d


Sample Output 2

[ 'player', 'read', 'trend' ]



['dreamer', 'player', 'reader', 'writer', 'trendy']

p

er 

Expected

[ 'dreamer', 'player', 'reader', 'writer' ]

Your Output

[ 'player' ]


String Slicing

Given two strings

inputString and subString as inputs, write a JS program to slice the inputString if it includes the subString. Slice the inputString starting from the subString to the end of the inputString.Input

  • The first line of input contains a string inputString
  • The second line of input contains a string subString

Output

  • The output should be a sliced string or inputString (if the inputString does not include the subString)


Sample Input 1

JavaScript

S


Sample Output 1

Script


Sample Input 2

Language

air


Sample Output 2

Language


Please help me.



 Given product code, name, and price for n=7 products as shown in the code snippet

below.

prod = [11, 22, 32, 44, 55, 66, 77]

name = ['aaa', 'bbb', 'ccc', 'ddd', 'eee', 'fff', 'ggg'] price = [1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7]

Generate a discounted price report given the below discounts:

20% discount if price is more than $400.00

15% discount if price is between $300.00 and $400.00 (both inclusive) 10% discount if price is less than $300.00

Your output should resemble as follows:

      Discounted Price List

No.   Code    Name    Price

1 xxx xxx xxx

2 xxx xxx xxx

...

New Price xxx

xxx


Write the definition of void function that takes as input two parameters of type int, double and string.the functions seta the values of int and double variable to 0 and the value of the string variable to the empty string



Solve this Backtracking Question in C++


A two dimensional array of characters can be considered as a field. Each cell is either water 'W' or

a tree 'T'. A forest is a collection of connected trees. Two trees are connected if they share a side

i.e. if they are adjacent to each other. Your task is, given the information about the field, print the

size of the largest forest. Size of a forest is the number of trees in it. See the sample case for clarity;

Sample Input:

5

TTTWW

TWWTT

TWWTT

TWTTT

WWTTT

Sample Output:

10


Speed Typing Test

In this assignment, let's build a Speed Typing Test by applying the concepts we learned till now.

Refer to the below image.

https://assets.ccbp.in/frontend/content/dynamic-webapps/speed-typing-test-output.gif

The Url will show you the required output to be generated.


Instructions:

  • Add HTML container element with id speedTypingTest
  • Add HTML paragraph elements with id timer, quoteDisplay and result
  • Add HTML textarea element with id quoteInput
  • Add HTML button elements with id submitBtn and resetBtn
  • Add the Bootstrap component spinner

By following the above instructions, achieve the given functionality.

  • When the page is opened
  • Make a HTTP request to get a random quotation
  • URL: https://apis.ccbp.in/random-quote
  • Display the random quotation in the HTML paragraph element with id quoteDisplay
  • Start the timer and display the time in seconds in the HTML paragraph element with id timer
  • When a value is entered in the HTML textarea element with id quoteInput and the HTML button element with id submitBtn is clicked
  • If the value entered in the HTML textarea element with id quoteInput is same as the quotation in the HTML paragraph element with id quoteDisplay
  • The timer should be stopped and a success message should be shown in the HTML paragraph element with id result
  • If the value entered in the HTML textarea element with id quoteInput does not match the quotation in the HTML paragraph element with id quoteDisplay
  • The timer should be running and an error message should be shown in the HTML paragraph element with id result
  • When the HTML button with id resetBtn is clicked
  • Make a HTTP request to get a new random quotation
  • Display the new random quotation in the HTML paragraph element with id quoteDisplay
  • Reset the timer to 0 seconds and display the time in seconds in the HTML paragraph element with id timer
  • Empty the HTML textarea element with id quoteInput
  • Add loading status with Bootstrap component spinner while making an HTTP request.

Resources

Clock Image:

  • https://assets.ccbp.in/frontend/dynamic-webapps/clock-img.png


CSS Colors Used:

Background Color Hex Codes Used:

#690cb0

#dac0ff

#f3eaff

#f2ebfe

#ffffff


Border Color Hex Codes Used:

#9aa5b1


Text Color Hex Codes Used:

#690cb0

#3e4c59

#ffffff

#323f4b

  • When the text in the HTML paragraph element with id quoteDisplay and the value entered in HTML textarea element with id quoteInput are not the same, and the HTML button element with id submitBtn is clicked an error message should be shown in the HTML paragraph element with id result


  • Page should consist of HTML textarea element with id quoteInput


  • Page should consist of HTML button element with id resetBtn


  • When the text in the HTML paragraph element with id quoteDisplay and the value entered in HTML textarea element with id quoteInput are not the same, and the HTML button element with id submitBtn is clicked the timer should be running


  • When the text in HTML paragraph element with id quoteDisplay is entered in HTML textarea element, and the HTML button element with id submitBtn is clicked a success message should be shown in HTML paragraph element with id result


  • Page should consist of HTML paragraph element with id timer


  • The HTML paragraph element with id timer should always have numbers greater than or equals to 0


  • Page should be using the Bootstrap component Spinner


  • When the text in HTML paragraph element with id quoteDisplay is entered in HTML textarea element, and the HTML button element with id submitBtn is clicked the timer should stop


  • Paee should consist of HTML paragraph element with id quoteDisplay


  • Page should consist of HTML button element with id submitBtn


  • Page should consist of HTML paragraph element with id result


  • Page should consist of HTML container element with id speedTypingTest


  • JS code implementation should use classList.add and classList.remove to show and hide bootstrap spinner element


  • JS code implementation should use setInterval and clearInterval to implement timer


  • When the reset button is clicked, an HTTP request should be made to get a random quotation from the given URL and the value in the HTML paragraph element with id quoteDisplay should be replaced with quotation received in the response


  • When page is opened, an HTTP request should be made to get a random quotation from the given URL and the HTML paragraph element with id quoteDisplay should have the quotation received in the response.

This is the code for Getting all the channel_ids that uploaded at least one video in "AI/ML" or "Robotics" technologies between 2018 and 2021.


SELECT

 DISTINCT channel_id

FROM

 video

WHERE

 video_id >= 1

 AND name LIKE '%AI/ML%'

 OR name LIKE '%Robotics%'

 AND strftime('%Y', published_datetime) BETWEEN "2018"

 AND "2021"

GROUP BY

 channel_id

ORDER BY

 channel_id ASC;


Output Table:

channel_id
    351
    353
    364
    365
    377


But,

How can I Get all the channel_ids that uploaded at least 20 videos in "AI/ML", "Cyber Security", "Data Science" or "Robotics" technologies between 2018 and 2021.

Example: If a channel publishes 5 videos in AI/ML, 10 videos in Cyber Security and 5 videos in Data Science, consider the channel


the table data is very huge so, I cant send the complete table data.

please help me.


LATEST TUTORIALS
APPROVED BY CLIENTS