CTS Genc
CTS Genc
CTS Genc
truck.The program should ask the user to enter the quantity of diesel to fill up
the tank and the distance covered till the tank goes dry.Calculate the fuel
consumption and display it in the format (liters per 100 kilometers).
Convert the same result to the U.S. style of miles per gallon and display the
result. If the quantity or distance is zero or negative display ” is an Invalid
Input”.
The result should be with two decimal place.To get two decimal place refer the
below-mentioned print statement :
float cost=670.23;
Sample Input 1:
Sample Output 1:
Liters/100KM
13.33
Miles/gallons
17.64
Explanation:
Sample Output 2:
-5 is an Invalid Input
Sample Input 3:
Rs.100/pizza
Rs.20/puffs
Rs.10/cooldrink
Generate a bill for What Vohra has bought.
Sample Input 1:
Bill Details
No of pizzas:10
No of puffs:12
No of cooldrinks:5
Total price=1290
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Problem Statement – Ritik wants a magic board, which displays a character for a
corresponding number for his science project. Help him to develop such an
application.
For example when the digits 65,66,67,68 are entered, the alphabet ABCD are to be
displayed.
[Assume the number of inputs should be always 4 ]
Sample Input 1:
65-A
66-B
67-C
68-D
Sample Input 2:
115-s
116-t
101-e
112-p
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Problem Statement – FOE college wants to recognize the department which has
succeeded in getting the maximum number of placements for this academic year. The
departments that have participated in the recruitment drive are CSE,ECE, MECH. Help
the college find the department getting maximum placements. Check for all the
possible output given in the sample snapshot
Note : If any input is negative, the output should be “Input is Invalid”. If all
department has equal number of placements, the output should be “None of the
department has got the highest placement”.
Sample Input 1:
Highest placement
CSE
Sample Input 2:
Highest placement
ECE
MECH
Sample Input 3:
Input is Invalid
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Problem Statement – In a theater, there is a discount scheme announced where one
gets a 10% discount on the total cost of tickets when there is a bulk booking of
more than 20 tickets, and a discount of 2% on the total cost of tickets if a
special coupon card is submitted. Develop a program to find the total cost as per
the scheme. The cost of the k class ticket is Rs.75 and q class is Rs.150.
Refreshments can also be opted by paying an additional of Rs. 50 per member.
Hint: k and q and You have to book minimum of 5 tickets and maximum of 40 at a
time. If fails display “Minimum of 5 and Maximum of 40 Tickets”. If circle is
given a value other than ‘k’ or ‘q’ the output should be “Invalid Input”.
Sample Input 1:
Ticket cost:4065.25
Sample Input 2:
Sample Input 1:
Season:Autumn
Sample Input 2:
Invalid month
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Problem Statement – To speed up his composition of generating unpredictable
rhythms, Blue Bandit wants the list of prime numbers available in a range of
numbers.Can you help him out?
Write a java program to print all prime numbers in the interval [a,b] (a and b,
both inclusive).
Note
Input 1 should be lesser than Input 2. Both the inputs should be positive.
Range must always be greater than zero.
If any of the condition mentioned above fails, then display “Provide valid input”
Use a minimum of one for loop and one while loop
Sample Input 1:
15
Sample Output 1:
2 3 5 7 11 13
Sample Input 2:
Sample Output 2:
Sample Input 1 :
21212
Sample Output 1 :
Palindrome
Sample Input 2 :
6186
Sample Output 2 :
Not a Palindrome
~~~~~~~~~~~~~~~~~~~~~~~~~
XYZ Technologies is in the process of increment the salary of the employees. This
increment is done based on their salary and their performance appraisal rating.
If the appraisal rating is between 1 and 3, the increment is 10% of the salary.
If the appraisal rating is between 3.1 and 4, the increment is 25% of the salary.
If the appraisal rating is between 4.1 and 5, the increment is 30% of the salary.
Help them to do this, by writing a program that displays the incremented salary.
Write a class “IncrementCalculation.java” and write the main method in it.
Sample Input 1 :
Sample Output 1 :
8800
Sample Input 2 :
Sample Output 2 :
9750
Sample Input 3 :
Sample Output 3 :
Invalid Input
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Problem Statement – Chaman planned to choose a four digit lucky number for his car.
His lucky numbers are 3,5 and 7. Help him find the number, whose sum is divisible
by 3 or 5 or 7. Provide a valid car number, Fails to provide a valid input then
display that number is not a valid car number.
Note : The input other than 4 digit positive number[includes negative and 0] is
considered as invalid.
Sample Input 1:
Lucky Number
Sample Input 2:
Sample Input 1:
Enter no of course:
5
Oracle
C++
Mysql
Dotnet
Sample Output 1:
Sample Input 2:
Enter no of course:
3
Oracle
Dotnet
Sample Output 2:
Sample Input 3:
Enter no of course:
0
Sample Output 3:
Invalid Range
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Problem Statement – Mayuri buys “N” no of products from a shop. The shop offers a
different percentage of discount on each item. She wants to know the item that has
the minimum discount offer, so that she can avoid buying that and save money.
[Input Format: The first input refers to the no of items; the second input is the
item name, price and discount percentage separated by comma(,)]
Assume the minimum discount offer is in the form of Integer.
Note: There can be more than one product with a minimum discount.
Sample Input 1:
mobile,10000,20
shoe,5000,10
watch,6000,15
laptop,35000,5
Sample Output 1:
shoe
Explanation: The discount on the mobile is 2000, the discount on the shoe is 500,
the discount on the watch is 900 and the discount on the laptop is 1750. So the
discount on the shoe is the minimum.
Sample Input 2:
Mobile,5000,10
shoe,5000,10
WATCH,5000,10
Laptop,5000,10
Sample Output 2:
Mobile
shoe
WATCH
Laptop
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Problem Statement – Raj wants to know the maximum marks scored by him in each
semester. The mark should be between 0 to 100 ,if goes beyond the range display
“You have entered invalid mark.”
Sample Input 1:
Enter no of semester:
3
Sample Output 1:
Enter no of semester:
3
Problem Statement – Bela teaches her daughter to find the factors of a given
number. When she provides a number to her daughter, she should tell the factors of
that number. Help her to do this, by writing a program. Write a class
FindFactor.java and write the main method in it.
Note :
If the input provided is negative, ignore the sign and provide the output. If the
input is zero
If the input is zero the output should be “No Factors”.
Sample Input 1 :
54
Sample Output 1 :
1, 2, 3, 6, 9, 18, 27, 54
Sample Input 2 :
-1869
Sample Output 2 :
~~~~~~~~~~~~~~~~~~~~~
You want to buy a particular stock at its lowest price and sell it later at its
highest price. Since the stock market is unpredictable, you steal the price plans
of a company for this stock for the next N days.
Find the best price you can get to buy this stock to achieve maximum profit.
Input Specification:
Input1: N, number of days
Input2: Array representing change in stock price for the day.
Output Specification:
Your function must return the best price to buy the stock at.
Example1:
Input1: 5
Input2: (-39957,-17136,35466,21820,-26711}
Output: -57093
Explanation: The best time to buy the stock will be on Day 2 when the price of the
stock will be -57093.
Example2:
Input1: 5
Input2: (-39957, -17136, 1, 2, -26711)
Output: -80801
Explanation: The best time to buy the stock will be on Day 5 when the price of the
stock will be -83801.
Example3:
Input1: 9
Input2: (-4527,-1579,-38732,-43669,-9287,-48068,-30293,-30867,18677}
Output: -207022
Explanation: The best time to buy the stock will be on Day 8 when the price of the
stock will be -207022.
~~~~~~~~~~~~~~~~
Given a positive whole number n, find the smallest number which has the very same
digits existing in the whole number n and is greater than n. In the event that no
such certain number exists, return – 1.
Note: that the returned number should fit in a 32-digit number, if there is a
substantial answer however it doesn’t fit in a 32-bit number, return – 1.
Example 1:
Input: n = 12
Output: 21
Explanation: Using the same digit as the number of permutations, the next greatest
number for 12 is 21.
Example 2:
Input: n = 21
Output: -1
Explanation: The returned integer does not fit in a 32-bit integer
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Henry is extremely keen on history and every one of the ages of his family. He does
a ton of exploration and understands that he has plummeted from the incomparable
Amaya line. After a ton of looking through old records and the most recent records
of the general public, he can discover all the parent-kid connections in his family
right from the extraordinary ruler Ming of the tradition to himself.
These connections are given in the structure of a direct exhibit where the emperor
is at the main position and his kids are at pos (2i + 1) and (2i + 2)
Henry needs to sort out every one of the kin of individual X from the information.
Write a program for Henry to figure out all the siblings of person X from the data.
Return the sorted list of all of Henry’s siblings.
Example 2 :
input 1: 6
input 2: {1,2,3,4,5,6}
input 3: 5
output: {4,6}
Explanation: {2,3 } are the children of {1}. {4,5,6 } are the children of {2,3},
thus the siblings of x= 5 are {4,6}
~~~~~~~~~~~~~~~~~~~~~~~~~~
Rohan and his team are participating in the Treasure Hunt event of college in which
in each step they have to solve one problem to get a clue about the Treasure
location. Rohan’s team has performed very well and reached the final step where
they have to provide a code of a problem to get a final clue about treasure .
Given a string s, they need to find the longest palindromic subsequence’s length in
s.
A subsequence is a sequence that can be derived from another sequence by deleting
some or no elements without changing the order of the remaining elements.
Write a program to help Rohan’s team that takes in input as String x and returns
the length of the longest palindromic subsequence of x.
Input Specification:
input1: string input
Output Specification:
Return the length of the longest palindromic subsequence
Example 1:
Input: s = “bbbab”
Output: 4
Explanation: One possible longest palindromic subsequence is “bbbb”.
Example 2:
Input: s = “cbbd”
Output: 2
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Given a number n, the task is to find the remainder when n is divided by 11. The
input number may be very large.
Since the given number can be very large, you can not use n % 11.
Input Specification:
inputs a large number in the form of a string
Output Specification:
Return the remainder modulo 11 of input1
Example1:
Input: str = 13589234356546756
Output: 6
Example2:
Input: str = 3435346456547566345436457867978
Output: 4
Example3:
input: str = 121
Output: 0
~~~~~~~~~~~~~~~~~~~~~~~~~~
Jasleen has bought a new bulb factory. The factory has a single file of machines,
numbered from 1 to N. Each machine has a certain number of fully prepared bulbs.
Jasleen has a rule she wants to follow. She wants to collect an equal amount of
bulb from
each machine from which she collects bulbs.
Jasleen can start collecting bulb from any machine, but once she starts collecting,
she collects
from every consecutive machine until she reaches the last machine she wants to
collect from. Find the maximum number of bulbs she can collect.
Input Specification:
Input1: N, the number of machines
Input2: An array of N elements (a1,a2 a3……aN], denoting the number of fully
prepared bulbs in each machine of the factory.
Output Specification:
An integer output denoting the maximum number of bulbs that Allie can collect.
Example 1:
input1: 3
Input2: [1,2,3]
~~~~~~~~~~~~~~~~~~~~~~~~
An astrologer gives a matrix to devilliers and tells him to add a largest row sum
and largest column sum of the given matrix.The number which appears as a result is
his lucky number for the final match jersey.
Write a program that adds up the largest row sum and the largest column sum from an
N- rows*M-columns array of numbers to help devilliers for finding his lucky number
for the final match jersey.
Input Specification:
Output: 26
Explanation:
The array has 4 rows (input1) and 4 columns (input2). The largest sum among the
four columns is 10 and the largest sum among the four rows is 16. We get the final
sum of 26 (10+16).
Example 2:
Input1:2
Input2: 2
Input3: {1,2,5,6}
Output: 19
Explanation:
The array has 2 rows (input1) and 2 columns (input2). The elements in the first row
are 1 and 2 and the elements in the second row are 5 and 6 (input3). The largest
sum among the two columns is 8(2+6) By adding those two up. We get the final sum of
19 (11+8).
Example 3:
Input1: 3
Input2: 3
Input3: {3,6,9,1,4,7,2,8,9}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Williamson is an analyst he needs to analyse a particular topic for performing
analysis for that he needs to find a permutation of a given object.He don’t know
how to find permutation so for simplifying his work he is hiring one software
developer who can code for him and find a permutation and combination of a given
object.
Consider you are giving an interview to williamson for working with him. Find a
permutation of given input to proof that you are fit for his requirement.
Input Specification:
nCr where n and r are numbers given by Williamson to you
nCr is defined as n! / (r! x (n-r)!)
Here, n! denotes the factorial of a number. Also, you have to calculate this number
as modulo
Input Specification:
Output:3
Explanation:
n=3.r=2,m=100 So, n!=3!=6, r!=2!=2, (n-1)!= 1!=1.
So, nCr = (6/(2*1))%1000000009= 3.
Example 2:
input1: 5
input2: 2
input3: 1000000009
Output: 10
Explanation:
n=5,r=2, m=100 So, n!=5!=120, r!=2=2, (n-1)!= 3!=6.
So, nCr = (120/(2*6))%1000000009= 10.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
A Derangement is a permutation of n elements, such that no element appears in its
original position.
For example, a derangement of {0, 1, 2, 3} is {2, 3, 1, 0}.
Given a number n, find the total number of Derangements of a set of n elements.
Input Specification:
input1: N, the number of Objects
Output Specification:
Return the number of arrangements in which no object occurs at its original
position
Example 1:
Input: n = 2
Output: 1
For two elements say {0, 1}, there is only one possible derangement {1, 0}
Example 2:
Input: n = 3
Output: 2
For three elements say {0, 1, 2}, there are two possible derangements {2, 0, 1} and
{1, 2, 0}
Example 3:
Input: n = 4
Output: 9
For four elements say {0, 1, 2, 3}, there are 9 possible derangements {1, 0, 3, 2}
{1, 2, 3, 0} {1, 3, 0, 2}, {2, 3, 0, 1}, {2, 0, 3, 1}, {2, 3,1, 0}, {3, 0, 1, 2},
{3, 2, 0, 1} and {3, 2, 1, 0}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Vira writes an apology letter to anu. However, before Anu can read it, Vira’s enemy
Rohan takes it and rotates the characters of each word left to right N times. Find
the number of words that remain the same even after this shifting of letters.
Input Specification:
Output : 2
Example 2:
input1: Sorry
input2: 2
Output : 0
~~~~~~~~~~~~~~~~~~~~~~~~~~
After Watching a movie at PVR, Adil is pondering over the number of ways in which
he can pay for the movie. He has x1, x2, x3, x4 coins of values 1,2,5 and 10
respectively. He wants to determine the number of ways in which he can pay an
amount A.
You need to fill in a function that returns the number of ways to pay total amount
Input Specifications:
Input 1: An integer value denoting the total amount to be paid
Output Specification:
Return an Integer value denoting the number of ways to pay the total amount
Example 1:
Input1: 40
Output : 195
Example 2:
Input1: 4
Output : 3
1 2 5 10
4
1
~~~~~~~~~~~~~~~~~~~~~~~~~~