1. Write a Java program to find maximum product of two integers in a given array of integers.
Example:
Input :
nums = { 2, 3, 5, 7, -7, 5, 8, -5 }
Output:
Pair is (7, 8), Maximum Product: 56
1. Write a Java program to rearrange a given array of unique elements such that every second element of the array is greater than its left and right elements.
Example:
Input :
nums= { 1, 2, 4, 9, 5, 3, 8, 7, 10, 12, 14 }
Output:
Array with every second element is greater than its left and right elements:
[1, 4, 2, 9, 3, 8, 5, 10, 7, 14, 12]
2. Write a Java program to form the largest number from a given list of non-negative integers.
Example:
Input :
nums = {1, 2, 3, 0, 4, 6}
Output:
Largest number using the given array numbers: 643210
3. Write a Java program to shuffle a given array of integers.
1. Write a Java program to find the maximum and minimum value of a 1-d array.
2. Write a Java program without using a second array to reverse elements of each row of a 2-d array of integer values.
e.g. 1 2 3 4 4 3 2 1
5 6 7 8 è 8 7 6 5
9 10 11 12 12 11 10 9
3. Write a java program to print the Pascal’s Triangle using a 2-d array.
4. Write a Java program to convert an array to an ArrayList, and an ArrayList to an array.
5. Write a Java program to arrange the elements of a given array of integers where all negative integers appear before all the positive integers.
6. Given two sorted arrays A and B of size p and q, write a Java program to merge elements of A with B by maintaining the sorted order i.e. fill A with first p smallest elements and fill B with remaining elements.
2.
Assume that each of the following statements applies to the same program.
a.
Write a statement that opens file
oldmast.dat
for
input; use an ifstream object called
inOldMaster.
b.
Write a statement that opens file
trans.dat
for reading
and writing data to it; use fstream object
transFile
that can read data from the file trans.dat
as well as write data to it.
c.
Write a statement that writes a record to the transfile. The record to store consist of an integer data
accountNumber
, and a floating point data
dollarAmount
1.Find the error(s) and show how to correct it(them) in each of the following.a.Filepets.datthat stores its id, name, age and ownerof the pet is referred to by ofstream objectpetfile.petfile>>pet_id>>pet_name>>pet_age>>pet_owner;b.The following statement should create an ifstream objectsalesfilethat refers to the fileweeklysales.datthat contains data about the id thesalesperson, total sales generated, and theweek number, read the data from the file and display it on the console output.ifstream salesfile(“weeklysales.dat”);int id,wk;float sales;salesfile>>id>>wk>>sales;while (!salesfile.eof()){cout<<id<<”\t”<<sales<<”\t”<<wk<<”\n”;salesfile<<id<<wk<<sales;}c.The salaries.dat should be updated to include the salary details of new employees. An ofstreamobject is created to refer to the file so new data can be added at the end of the file.ofstream salfile;salfile.open(“salaries.dat”,ios::out);
Find the error(s) and show how to correct it(them) in each of the following.
a.
File
pets.dat
that stores its id, name, age and owner
of the pet is referred to by ofstream object
petfile
.
petfile>>pet_id>>pet_name>>pet_age>>pet_owner;
b.
The following statement should create an ifstream object
salesfile
that refers to the file
weeklysales.dat
that contains data about the id the
salesperson, total sales generated, and the
week number, read the data from the file and display it on the console output.
ifstream salesfile(“weeklysales.dat”);
int id,wk;
float sales;
salesfile>>id>>wk>>sales;
while (!salesfile.eof()){
cout<<id<<”\t”<<sales<<”\t”<<wk<<”\n”;
salesfile<<id<<wk<<sales;
}
1. Create a database and do the Triggers.
Using the syntax of creating Triggers.
o After Insert
o Before Insert
o After Update
o Before Update
o After Delete
o Delete Trigger
Create a database and tables.
Import any data with 10 values.
Provide me the sql file or screenshot per commands and show the
BEFORE and AFTER of the data.
Given a positive integer n, list all the bit sequences of length n that do not have a pair of consecutive 0s. Write a C or C++ program to solve this problem. The input is an integer n
Run your program on the following six inputs: n = 6, 7, 8, 9, 10, 11
if a given integer in "N". write a program to print the right angled triangle pattern of "N" rows and there is a lhytopenus line using "/" of same number
-------
|
|
|
|
|
|
|
implement the class Loan with the following requirements:
•
A member variable that will hold the annual interest rate of the loan. Its default value will be 2.5.
•
A member variable that will hold the number of years for the loan. Its default value will be 1.
•
A member variable that will hold the loan amount. Its default variable will be 1000.
•
A default constructor.
•
Another constructor that has interest rate, years, and loan amount as its parameters.
•
A member function that returns the annual interest rate of this loan.
•
A member function that returns the number of the years of this loan.
•
A member function that returns the amount of this loan.
•
A member function that sets a new annual interest rate to this loan.
•
A member function that sets a new number of years to this loan.
•
A member function that sets a new amount to this loan.
•
A member function that returns the monthly payment of this loan