Skip to content

Priyanshu845438/Java_TImePass_Practice

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Program 1 - Determine Department Based on Seat Number

Day 1 - Week 1
A classroom is arranged in a grid format with row rows and col columns.

  • The first and last columns are for CSE students.
  • The middle columns are for ECE students.

Input: Number of rows, columns, and a seat number.
Output: The department (CSE or ECE) to which the seat belongs.


Program 2 - Print a Basic Java Program

Day 1 - Week 1
Write a simple Java program (e.g, Hello World or basic input/output).


Program 3 - Sum of First and Last Digit

Day 1 - Week 1
Given a 4-digit number, extract the first and last digits and print their sum.


Program 4 - Reverse a 3-Digit Number

Day 2 - Week 1
Write a program to reverse a given three-digit number.


Program 5 - Pirate Treasure Distribution

Day 2 - Week 1
Input:

  • Total gold treasure
  • Ben’s share percentage
  • Blackbeard’s share percentage

Output:

  • Ben’s share amount
  • Blackbeard’s share amount
  • Remaining gold is to be equally divided among 3 other pirates.

Program 6 - Evaluate a 2-Digit Number

Day 2 - Week 1
Take a 2-digit number as input.

  • If it is less than 20, print "Less than 20"
  • If it is greater than or equal to 20, print whether it is odd or **even`

Program 7 - Check Trendy Number

Day 2 - Week 1
Input: An integer n
Output:

  • If n is not a 3-digit number → "Invalid Number"
  • If the middle digit of the 3-digit number is divisible by 3"Trendy Number"
  • Else → "Not Trendy Number"

Program 8 - Hotel Tariff Calculation (HW)

Day 2 - Week 1
Calculate hotel tariff with 20% increase during the season (April–June and November–December).

Input:

  1. Month number (1–12)
  2. Rent per day
  3. Number of days

Output:

  • Print the total tariff
  • If the month is invalid, print "Invalid Input"

Program 9 - Weird or Not Weird

Day 2 - Week 1
Input: An integer n
Rules:

  • If n is odd, print "Weird"
  • If n is even and in the range [2, 5], print "Not Weird"
  • If n is even and in the range [6, 20], print "Weird"
  • If n is even and greater than 20, print "Not Weird"

Program 10 - Print Odd Numbers (1 to 9)

Day 2 - Week 1
Print all odd numbers from 1 to 9 using a while loop.


Program 11 - Print 0 to 9 Using Do-While Loop

Day 2 - Week 1
Print numbers from 0 to 9 using a do-while loop.


Program 12 - Sum Even & Odd Digits and Count Digits

Day 3 - Week 1
Given an integer, calculate:

  • Sum of even digits
  • Sum of odd digits
  • Total number of digits

Program 13 - Count All-Odd Digit Numbers (1 to 110)

Day 3 - Week 1
Count how many numbers between 1 and 110 consist of only odd digits.


Program 14 - Nearest Integer Divisible by 'm'

Day 3 - Week 1
Function Signature:
int NearestInteger(int num, int m);

Requirements:

  • Return the number divisible by m and closest to num.
  • If two numbers are equally close, return the larger one.

Example:
Input: 67, m = 8 → Output: 64


Program 15 - Print Nearest Divisible Number

Day 3 - Week 1
Given two numbers, print the number nearest to the first number that is divisible by the second number.


Program 16 - Reduce to Single Digit Sum

Day 3 - Week 1
Write a program to repeatedly sum the digits of a number until the result is a single digit.


Program 17 - Check Harshad Number

Day 4 - Week 1
A number is a Harshad Number if it is divisible by the sum of its digits.


Program 18 - Check Adam Number

Day 4 - Week 1
A number is an Adam Number if the square of the number, when reversed, equals the square of the reverse of the number.

Example:

  • Input: 12
  • Square(12) = 144
  • Reverse(Square) = 441
  • Reverse(12) = 21 → Square = 441

Program 19 - Armstrong Number

Day 4 - Week 1
An Armstrong number is a number where the sum of the digits raised to the power of number of digits is equal to the number itself.
Example: 153 → 1^3 + 5^3 + 3^3 = 153


Program 20 - Kaprekar Number

Day 4 - Week 1
A number is a Kaprekar Number if:

  • k^2 is split into two parts that sum to k.
    Examples:
  • 9 → 81 → 8 + 1 = 9
  • 297 → 88209 → 88 + 209 = 297

Program 21 - Strong Number

Day 4 - Week 1
A number is a Strong Number if the sum of the factorials of its digits equals the number.
Examples:

  • 145 → 1! + 4! + 5! = 145
  • 40585 → 4! + 0! + 5! + 8! + 5! = 40585

Program 22 - Print Right-Angled Triangle Pattern

Week 1 - Day 4
Take input a number from the user and print the Right-Angled Triangle Pattern.


Program 23 - Print Inverted Right-Angled Triangle Pattern

Week 1 - Day 4
Take input a number from the user and print the Inverted Right-Angled Triangle Pattern.


Program 24 - Staircase Pattern

Week 1 - Day 5
Print the Left-Aligned Staircase Pattern based on the input number of rows.


Program 25 - Reverse Staircase Pattern

Week 1 - Day 5
Print the Right-Aligned Reverse Staircase Pattern based on the input number of rows.


Program 26 - Print Square Pattern with Border

Week 1 - Day 5
Print a Square Pattern with Star Border and Empty Center.


// Program 27 // Week 1 - Day 5 // Print Traingle Pattern center empty


// Program 28 // Week 1 - Day 5 // Print first four alphabate of name in pattern by using *


// Program 29 // Week 1 - Day 5 // Arrays // Sum of all the elements in the array


// Program 30 // Week 1 - Day 5 // Subtract of all the elements in the array // imput: 1-2-3-4-5 // Output: -13


// Program 31 // Week 1 - Day 5 // Note: Two arrays are said to be the same if the sum of both arrays os the same and the size of the array is the same // Input: Input consist of 2 integers and 2 array. The integer should corrospend to the size of the array

// Output: //4 //4 //1 //2 //3 //4 //1 //2 //3 //4


// Program 32 // Week 1 - Day 6 // Input consists of 2n + 2 integers. The first integer correspond to n1. the size of arrat. The next n1 integre correspond to the elements in the first array. The next (n + 1) integer corresponds to n2. the size of the second array. The last n2 integers correspond to the elements in the second array. // Output : Compatible array or incompatible array


// Program 33 // Week 1 - Day 6 // Array insertion by not removing any existing elements.


// Program 34 // Week 1 - Day 6 // Write a program to remove all the duplicate elements from an array.


// Program 35 // Week 1 - Day 6 // Cubic Sum: Given function: //Int isCubicSumExist(long long int A[], int N); // The function accept an array A of size N and returns 1 if there exists a pair of elements in the array such that their sum is a perfect cube. Otherwise, it returns 0. // Input: N:3, A:[35,9,1] // Output: 2 // Explanation: 35 is a good integre, there exist an answer with X = 2, y = 3(23 + 33 = 8 + 27 = 35)


About

Java Interview Questions and Solutions

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Languages