Skip to main content

Posts

ISC Program: Predict day of the week from date

Algorithm : 1)Take the last two digits of the year. 2)Divide by 4, discarding any fraction. 3)Add the day of the month. 4)Add the month's key value: JFM AMJ JAS OND 144 025 036 146 5)Subtract 1 for January or February of a leap year. 6)For a Gregorian date, add 0 for 1900's, 6 for 2000's, 4 for 1700's, 2 for 1800's; for other years, add or subtract multiples of 400. 7)For a Julian date, add 1 for 1700's, and 1 for every additional century you go back. 8)Add the last two digits of the year. 9)Divide by 7 and take the remainder. Example : Let's take a date: 26/03/2027 Last two digit of the year = 27 Divide by 4 discard fraction = 27/4 = 6.75 = 6 Add day = 6 + 26 = 32 Month key = 4 + 32 = 36 Add year code = 36 + 6 = 42 Now add two digits of the first year = 42 + 27 = 69 Now get the remainder after dividing by 7 = 69%7=6 So 1 is Sunday so 6 is Friday So 27/03/2027 Program : import java.util.Scanner; public class daydate {     public static void main(String[] arg...
Recent posts

ISC Program : Position deletion in a sentence

  WAP to accept  a sentence which may be terminated by either , ; ? . or !(Any other character may be ignored). The words may be separated by more than one blank space and are in upper case. Perform the following tasks: (i) Accept the sentence and reduce all extra blank spaces between two words to a single blank space. (ii) Accept a word from the user which is a part of the sentence along with its position number and delete the word and display the distance. Example: Input: AS YOU SOW,SO SO YOU REAP. AS YOU SOW,SO SO YOU REAP Word To be deleted : SO Word position in the sentence: 4 Output: AS YOU SOW,SO YOU REAP import java.util.*; public class code {     public static void main( String [] args) {         Scanner sc= new Scanner(System.in);         System.out.println( "Enter a sentence:" );         String m = sc.nextLine();         char ch = m.charAt(m.length()- 1 );   ...

ISC 2021 Program: Fascinating Number

Write a Program in Java to input a number and check whether it is a Fascinating Number or not. Fascinating Numbers: Some numbers of 3 digits or more exhibit a very interesting property. The property is such that, when the number is multiplied by 2 and 3, and both these products are concatenated with the original number, all digits from 1 to 9 are present exactly once, regardless of the number of zeroes. Let's understand the concept of Fascinating Number through the following example: Consider the number 192 192 x 1 = 192 192 x 2 = 384 192 x 3 = 576 Concatenating the results: 192 384 576 It could be observed that '192384576' consists of all digits from 1 to 9 exactly once. Hence, it could be concluded that 192 is a Fascinating Number. Some examples of fascinating Numbers are: 192, 219, 273, 327, 1902, 1920, 2019 etc. /**  * suppose 192  * 192x1=192  * 192x2=384  * 192x3=576  * 192384576  * no single digit should repeat */ import java.util.Scanner; class fasc...

LED Brightness Control with Potentiometer

 LED Brightness Control with Potentiometer Circuit Components

Slideswitched LEDs with Buzzer

 Slideswitched LEDs with Piezo Buzzer Components List

Pushbutton Controlled RGB LED Circuit with 9V Battery and LM7805 Voltage Regulator

 Pushbutton Controlled RGB LED Circuit with 9V Battery and LM7805 Voltage Regulator Connection Components

OpenCV Tutorial

 OpenCV #as you can see the above image is not presented as the original # OpenCV #for exact representaition import cv2 from matplotlib import pyplot as plt import numpy as np img = cv2.imread(r'C:\Users\shrey\code\puppy.jpg') #loads the puppy image to img variable plt.imshow(cv2.cvtColor(img,cv2.COLOR_BGR2RGB)) plt.title("Cute Puppies") plt.axis("off") plt.show() #as you can see the above image is not presented as the original # OpenCV #for exact representaition import cv2 from matplotlib import pyplot as plt import numpy as np img = cv2.imread(r'C:\Users\shrey\code\puppy.jpg') #loads the puppy image to img variable plt.imshow(cv2.cvtColor(img,cv2.COLOR_BGR2RGB)) plt.title("Cute Puppies") plt.axis("off") plt.show() # OpenCV #for Gray image import cv2 from matplotlib import pyplot as plt import numpy as np img = cv2.imread(r'C:\Users\shrey\code\puppy.jpg',0) #loads the puppy image to img variable plt.imshow(img,cmap='g...

Money Object Passing Program in Java

 /**    Money is an unit that has 2 parts, Rupees and Paise, where 100 Paise=1 Rupee. Design a  class named Money whose details are as follows: Class Name : Money Data member: int rs, ps  : integer to store the value of Rupees and paise. Member methods: Money(…..)     : parameterized constructor to initialize member data void fnShow()  : to show the member data as Money [Rs 819.75] Money fnAdd(Money m1, Money m2) : Add m1 and m2. Store the result in corresponding member data and return it. Specify the class Money, giving the details of the above member data and methods.  Also write the main() to create objects and call the other methods accordingly to  enable the task of the adding 2 units on Money.    */ import java.util.Scanner; public class Money {     int rs,ps;     Money(int rs,int ps)     {         this.rs=rs;         this.ps=ps;     } ...

Object Passing Program in Java: Point Coordinate Program

A class defines the coordinates of a point in a plane. The details of the class are given below: class name: point Instance variables: int x,y --> define the x and y coordinate void input(): To accept the x and y coordinates void calculate(point p): To pass the object which depicts the 2nd coordinate. Then find the distance between the two coordinates. import java.util.Scanner; public class Point  {     int x,y;     void input(){         Scanner sc=new Scanner(System.in);         System.out.println("Enter x coordinate:");         x=sc.nextInt();         System.out.println("Enter y coordinate:");         y=sc.nextInt();         sc.close();     }     void calculate(Point p)     {         int x1 = this.x;         int y1 = this.y;         int x2 = ...

Implementation of Dequeue(Double ended queue) in Java

 Implementation of Dequeue(Double ended queue) in Java class dequeue { //double ended queue int DQ[],f=-1,r=-1,size; dequeue(int size) { this.size=size; DQ = new DQ[size]; } void addFront(int data) { if(f==-1 && r==-1) { f=0;r=0; } else if(f==0) { System.out.println("Queue overflow"); } else{ f=f-1; } DQ[f]=data; } void deleteFront() { if(f==-1 && r==-1) { System.out.println("Queue underflow"); } int v=DQ[f]; System.out.println("Removed:"+v); f=f+1; } void addRear(int data) { if(f==-1 && rear==-1) { f=0; r=0; } else if(rear==(size-1)) { System.out.println("Queue Overflow"); } else { r=r+1; } DQ[r]=data; } void removeRear() { if(f==-1 && r==-1) { System.out.println("Queue is underflow"); } if(f==r) { System.out.println("Removed element is:"+DQ[r]); f=-1; r=-1; } else { System.out.println("Removed element is:"+DQ[r]); r=r-1; } } void display() { if(f==-1 && r==-1) System.out.prin...