A method called sine, which takes as its only parameter a value of type double, and returns a value
of type double. The parameter represents an angle expressed in radians, and the value returned by
the method represents the trigonometric sine of this angle. For example, suppose the following method
call is executed:
double sin = MathAssignment.sine(1.047197551);
After the execution of the above method call, the value stored in variable sin will be (approximately)
0.866025404, as the sine of 1.047197551 radians is approximately 0.866025404. The
sine of an angle x, denoted sin x, can be calculated using the following algorithm:
• If x < -π, repeatedly add 2π to x until -π ≤ x ≤ π. Conversely, if x > π, repeatedly subtract 2π
from x until -π ≤ x ≤ π. You MUST use 3.141592653589793 as a value
Searching an element in a sorted array
standard input/output: 2s/128000 kB
Given a sorted array arr[] of N integers and a number K is given. The task is to check if the element K is present in the array or not.
Note: Use binary search to solve the problem
Input
The first line of input contains a number of test cases T. For each test case, first line of input contains a number of elements in the array, and the number K separated by space. The next line contains N elements.
Constraints:
1 <= T <= 10
1 <= N <= 100000
1 <= K <= 1000000000
1 <= arr[i] <= 1000000000
Sum of N over all test cases doesn't exceed 106
Output
For each testcase, if the element is present in the array print "1" (without quotes), else print "-1" (without quotes).
GCD of LCM! (Contest)
standard input/output: 2s/128000 kB
You are given an array A consisting of N number and an empty set S. For each pair of numbers A[i] and A[j] in the array (i < j), you need to find their LCM and insert the LCM into the set S.
You need to report the GCD of the elements in set S.
Input
The first line of the input contains an integer N.
The second line of the input contains N space separated integers A[1], A[2],. , A[N].
Constraints
2 <= N <= 100000
1 <= A[i] <= 200000
Output
Output a single integer, the GCD of LCM set S.
Create a class called Student, with the following attributes/variables:
a. studentName (String)
b. studentNumber (int)s
c. regYear(long)
d. faculty(String)
e. department(String)
Create a class called Rational for performing arithmetic with fractions. Write a program to test your
class. Use integer variables to represent the private instance variables of the class—the numerator and
the denominator. Provide a constructor that enables an object of this class to be initialized when it’s
declared.
Write a program to take a String as input then display the words in one column, its length in another column, replace the first with last character of each word in third column.
Enter a String
a is the first vowel
a 1 a
is 2 si
the 3 eht
first 5 tirsf
vowel 5 lowev
Hint: Use length(),charAt(), indexOf(), substring() if required.
Array & split & ternary(:?) are not to be used
Write a program to test your
class. Use integer variables to represent the private instance variables of the class—the numerator and
the denominator. Provide a constructor that enables an object of this class to be initialized when it’s
declared. The constructor should store the fraction in reduced form. The fraction:
2/4 is equivalent to 1/2 and would be stored in the object as 1 in the numerator and 2 in the denominator.
Provide a no-argument constructor with default values in case no initializers are provided. Provide public
methods that perform each of the following operations:
Add two Rational numbers: The result of the addition should be stored in reduced form.
Subtract two Rational numbers: The result of the subtraction should be stored in reduced form.
Multiply two Rational numbers: The result of the multiplication should be stored in reduced
form.
Also, write a test program to test all methods, and provide the UML class diagram of your class.
Create class SavingsAccount. Use a static variable annualInterestRate to store the annual
interest rate for all account holders. Each object of the class contains a private instance variable
savingsBalance indicating the amount the saver currently has on deposit. Provide method
calculateMonthlyInterest to calculate the monthly interest by multiplying the
savingsBalance by annualInterestRate divided by 12—this interest should be added to
savingsBalance. Provide a method modifyInterestRate that sets the
annualInterestRate to a new value.
Write a program to test class SavingsAccount. Instantiate two savingsAccount objects, saver1
and saver2, with balances of $2000.00 and $3000.00, respectively. Set annualInterestRate to
4%, then calculate the monthly interest for each of 12 months and print the new balances for both savers.
Next, set the annualInterestRate to 5%, calculate the next month’s interest and print the new
balances for both savers. Also, provide the UML class diagram of your class.
Rotating alphabet T by 360 degrees in clockwise direction in java