Month: July 2017

Rhombus Pattern – N Slashes Side

              Rhombus Pattern – N Slashes Side Given an odd value of N, the program must print a rhombus in diamond shape whose side contains N slashes as shown below in the examples.Input Format:The first line contains N.Output Format:The rhombus in diamond shape with each side containing N slashes.

Max Winning Streak Game Points

Alok is playing N round of card games with his friend Brinda. He gets postive or negative points based on whether he won or lost in a specific round. Alok can also get zero points in case of a tie.Given the points obtained in N rounds, the program must print the maximum sum of points

2D Matrix Modification 001

                    2D Matrix Modification A Matrix has R rows and C columns. Get the matrix as input and multiply the value in the cells of the matrix by a value E if it is even and multiply it by a value F if it is odd.

Numbers – Range Count

                  Numbers - Range Count  Given N distinct integers, the program must print the number of ranges R present. A range is defined as two or more consecutive integers. Input Format:The first line contains N.The second line contains N integer values separated by a space. Output Format:The

Find the sum of multiples of X between A and B

Find the sum of multiples of X between A and B Given the values for X, A and B, the program must print the sum of multiples of X from A to B (inclusive of A and B).Input Format:The first line contains the value of X.The second line contains the value of A.The third line

Interface Implementation – Calculator

Interface Implementation – Calculator The interface Calculator.java is given below. Define the class SimpleCalculator.java so that it implements the interface Calculator and the program prints the desired output. public interface Calculator {    int add(int x, int y);       int subtract(int x, int y);    int multiply(int x, int y);    int divide(int x, int y); The invoking class with the main method is given below. import java.util.*;   public class Hello {       public static void main(String args) {         Scanner sc = new Scanner(System.in);

Target Practice

Drona normally trains his disciples using a board which consists of concentric circles. When the student correctly hits the center of the concentric circles, his score is 100. The score gets reduced depending on where the students hit on the board. When the student hits outside the board, his score is 0. Drona will not

Increasing Sequence

Increasing Sequence A sequence a, a1, ..., at - 1 is called increasing if ai - 1 < ai for each i: 0 < i < t. You are given a sequence b, b1, ..., bn - 1 and a positive integer d. In each move you may choose one element of the given sequence and add d to

No. of Distinct Elements in an unsorted array

No. of Distinct Elements in an unsorted array Write a program to find the number of distinct elements in a unsorted array. [Do it without sorting the array] Input Format: Input consists of n+1 integers.The first integer corresponds to n, the number of elements in the array.The next n integers correspond to the elements in

SQL – Select all 4th Year Students from IT department

    SQL - Select all 4th Year Students from IT department The students table has the following four columns id name department year The table DDL is as below. CREATE TABLE students(id int,name VARCHAR(100), department VARCHAR(3),year int); Write the SQL statement to fetch the records (all the columns) of the students belonging to year as 4 and department