Q2.Given an array String[] array ={"civic","level","check","oop","boss","madam","sir"}, write down the
program with method which will print only palindromes from the array. You can use
public static Boolean ifPalindrome()
public static void printPalindrome() as reference.
Your Output should look like:
civic
level
madam
(A palindrome is a word, a sequence of characters which reads the same backward as forward, such as
refer)
Question 1: [10]
You are given a .java code file named “Q1.java”. Your task is to read the comments in that
Also, you will need to write code in the main method and test all your methods.
Method Details
The details of the methods are as follows:
1. printIntArray Method
This method prints the values of the argument int array.
2. insertKey Method
This method inserts the given key value at index 0 in the array. If the array already has a value at index 0,
it will shift the values to the right and make space for the new key.
3. removeKey Method
This method performs the opposite function of the above method and removes and returns the key
To remove the first key, we will first store that value and then shift all values one place to the left as given
4. copyArray Method
This method copies all values from the argument array to a new array. It then returns the newly copied
array.
5. arraysEqual Method
This method returns true if both the argument arrays have the exact same values. Otherwise, returns false.
Using the NetBeans IDE, create a new project
Name the class as FactorialCalculator
Write a simple factorial calculator program. The program should perform the following
step 1. Ask the user to enter a positive integer
step 2. Check if the entered integer is positive or negative. if it is positive, perform step 3; otherwise, display an appropriate error message and the program should stop.
step 3. Calculate the factorial of the entered positive integer and display the result.
Note: The factorial of n is denoted by n! and calculated by the product of integer numbers from 1 to n. For example, the entered integer is 5, the calculation of its factorial is: 5! = 1 x 2 x 3 x 4 x 5 = 120.
Step 4. Repeat Step 1 to Step 3 five(5) times
Write a program to take a number as input then display the digits in the following format:
For example:
Input : 2315
Output: 5+1+3+2=11
Using following method prototype:
String generate(int n)
Using java.util package only
Write a program to take a number as input then display the digits in the following format:
For example:
Input : 2315
Output : 5+1+3+2=11
Using following method prototype:
String generate(int n)
What is wrong with JSON below? Please correct it.
{
"widget":{
"text":{
"data":"Click Here",
"size":36,
"name":text1",
"hOffset":250,
"vOffset":100,
"alignment":"center",
"onMouseUp":"sun1.opacity
= (sun1.opacity / 0) * 90;"
}
}
create a class with grade students to accept the score of a student and determine the grade thus 85-100=A+,80-84+A,75-79=B+,70-74=B,65-69=C+,60-64=C,55-59=D+,50-54=D,Below 50=f
Using Java with the selection statement ,create a class with grade students to accept the score of a student and determine the grade thus 85-100=A+,80-84+A,75-79=B+,70-74=B,65-69=C+,60-64=C,55-59=D+,50-54=D,Below
A hospital stores information about its doctors in a text file using the following format:
DoctorID;DoctorName;DoctorSpecialization;DoctorDepartment;DoctorSalary
Write a program with the following functionalities:
Write a Doctor class to store all the relevant information of the Doctor as mentioned above. toString() method to display the doctor’s information is also required.
Assume that the doctors data is stored in file at path “D://Doctors.txt”, write a program that reads doctors information one line at a time and store it in the objects of Doctor Class.
Write a Hospital class containing the ArrayList of Doctor objects read from the file. Write a sort method in the Hospital class that sorts all the Doctors in ascending order w.r.t. their salary and print their details.
Implement a java class hierarchy that represents at least three different types of exams: quizes, midterms, and finals. The base class called Exam must have three abstract methods called getPoints(), setPoints(), and getNormalizedScore(). In addition to that, each derived class must have a constructor which takes as parameters the minimum number of points for this exam (e.g. 0), the maximum number of points for the exam (e.g., 100), and the weight of this exam (e.g., 20%). All the fields must to have Private access modifier. Create setter and getter functions for each field. Create function which prints all fields.