Similar to previous, make Student class with 4 data members (name, roll no, GPA, credit hours) and 2 constructors (one user input, one file input) and a destructor.
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 KingString Ending with Vowel
Given an array of vowels in the prefilled code and a string
inputString as an input, write a JS program to check whether the inputString ends with a vowel.
Quick Tip
You can use the string methods toUpperCase() and endsWith().
Input
The input will be a single line containing a string inputString
Output
The output should be a single line containing a boolean value
Sample Input 1
Five
Sample Output 1
true
Sample Input 2
Apples grow best where there is cold in winter
Sample Output 2
false
Given an array
myArray of numbers, write a JS program to perform the following steps and log the result.
Multiply each value with 9.
Subtract 20 from each value.
Multiply each value with 7.
Log the values of the resulting array separated by a space.
Input
The input will be a single line containing an array myArray
Output
The output should be a single line with values separated by a space
Constraints
Each value in the array must be a number
Sample Input
[ 12, 2, 2, 4, 1 ]
Sample Output
616 -14 -14 112 -77
"use strict";
process.stdin.resume();
process.stdin.on("data", (inputStdin) => {
inputString += inputStdin;
});
process.stdin.on("end", (_) => {
inputString = inputString.trim().split("\n").map((str) => str.trim());
main();
});
function readLine() {
return inputString[currentLine++];
}
function main() {
const myArray = JSON.parse(readLine());
/* Write your code here */
}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.
Make two 3D-points in a 3-Dimensional space. Calculate the distance between these two points. Instead of integer data type, use any other datatype for x,y,z values. Create an object pt, and call distance function as pt.Distance(pt2), which will calculate the distance between two 3-D points.
Similar to previous, make Student class with 4 data members (name, roll no, GPA, credit hours) and 2 constructors (one user input, one file input) and a destructor.
Make a 3DPoint class with 2 constructors and a destructor. Constructor should take input from file_name passed, Constructor 2 should input from user. Destructor should output id of destructed object.
Make a 3DPoint class with constructor and destructor. The constructor should take input from the user. Destructor should output the id of the destructed object.
Create array of structure to store the details of voter. Create a menu for data creation, display, and check the availability of data and eligibility to vote. Also check if he is eligible to vote.