The Double. parseDouble() method requires a String argument, but it fails if the String cannot
be converted to a floating-point number. Write an application in which you try accepting a
double input from a user and catch a NumberFormatException if one is thrown. The catch
block forces the number to 0 and displays an appropriate error message. Following the catch
block, display the number. Save the file as TryToParseDouble.java
Write a program to find out the greatest between two numbers defined in two different classes by using friend function.
Write a menu driven program to perform the following operations in a header linked
list by using suitable user defined functions for each case. The head node keeps the
count of the total number of nodes in the list. The data node keeps the student
information: Name, Roll No, CGPA, Address_City, Branch.
1. Create
2. Display student information
3. Display the total number of nodes (in O(1) time)
4. Display the students’ details belonging to a particular branch
5. Display the students’ details securing > 7.5 CGPA and belonging to a given
branch.
Write a menu driven program to perform the following operations in a double linked list by
using suitable user defined functions for each case.
a) Traverse the list forward
b) Traverse the list backward
c) Check if the list is empty
d) Insert a node at the certain position (at beginning/end/any position)
e) Delete a node at the certain position (at beginning/end/any position)
f) Delete a node for the given key
g) Count the total number of nodes
h) Search for an element in the linked list
Verify & validate each function from main method.
Let a linked list consists of n number of nodes, where each node consists of a unique
number, a priority number (in between 1 to 5), and pointer to next node. Design the
algorithm/develop pseudocode to divide the nodes into different linked list where
each linked consists of nodes having same priority.
Add two polynomials:
Input
The first line contains a single integer M.
Next M lines contain two integers Pi, Ci separated with space, where Pi denotes power and Ci denotes co-efficient of Pi for polynomial A.
After that next line contains a single integer N.
Next N lines contain two integers Pj, Cj separated with space, where Pj denotes power and Cj denotes co-efficient of Pj for polynomial B.
Output
Print the addition of polynomials A and B.
The format for printing polynomials is: Cix^Pi + Ci-1x^Pi-1 + .... + C1x + C0, where Pi's are powers in decreasing order, Ci is co-efficient and C0 is constant, there will be space before and after the plus or minus sign.
If co-efficient is zero then don't print the term.
.Explanation
If M = 4 and for polynomial A
For power 0, co-efficient is 5
For power 1, co-efficient is 0
For power 2, co-efficient is 10
For power 3, co-efficient is 6.
If N = 3 and for polynomial B
For power 0, co-efficient is 1
For power 1, co-efficient is 2
For power 2, co-efficient is 4.
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.