Skip to main content

Posts

Showing posts from October, 2016

Java Tutorial For Beginners: Part 4.

Problem: Java Program To Implement Calculator Using Applet. import java.awt.*; import java.awt.event.*; import java.applet.*; public class Calculator extends Applet implements ActionListener { private static final long serialVersionUID = 1L; String msg=" "; int v1,v2,result; TextField t1; Button b[]=new Button[10]; Button add,sub,mul,div,clear,mod,EQ; char OP; public void init() { Color k=new Color(120,89,90); setBackground(k); t1=new TextField(10); GridLayout gl=new GridLayout(3,3); setLayout(gl); for(int i=0;i<10;i++){ b[i]=new Button(""+i); }

Java Tutorial For Beginners: Part 3.

Problem: Java Program To Find Factorial Of A Number import java.util.Scanner; class Factorial { public static void main(String args[]) { int n, c, fact = 1; System.out.print("Enter An Integer To Calculate It's Factorial: "); Scanner s = new Scanner(System.in); n = s.nextInt(); if ( n < 0 ) System.out.println("Number Must Be Non-negative."); else { for ( c = 1 ; c <= n ; c++ ) fact = fact*c; System.out.println("Factorial Of "+n+" Is = "+fact); s.close(); }}} Problem: Java Program To Find Factorial Of A Number Using Recursion import java.util.*; public class FactorialRecursion { public static void main(String args[]) { int num, factorial = 1; Scanner s = new Scanner(System.in); System.out.print("Enter An Integer To Calculate It's Factorial: "); num = s.nextInt(); if ( num < 0 ) System.out.println("Number Must Be Non-negative.");

A Comprehensive List Of Windows Run Commands.

The run command window is a fast and efficient way to directly access Windows' functions, without sifting through the Control Panel or other menus. I have summarized a comprehensive list of run commands that are tested in Windows 7, 8, and 10. The commands are not case-insensitive. Open the Run command window (press the windows Key + R). Afterward, type any of the following commands and click OK or press Enter. That’s it! Opens Press Windows + R and type: Open Documents Folder documents Open Videos folder videos Open Downloads Folder downloads Open Favorites Folder favorites Open Recent Folder recent Open Pictures Folder pictures Adding a new Device devicepairingwizard About Windows dialog winver Add Hardware Wizard hdwwiz Advanced User Accounts netplwiz Advanced User Accounts azman.msc Backup and Restore s

Java Tutorial For Beginners: Part 2.

Problem: Java Program To Solve Tower Of Hanoi Problem Using Stacks import java.util.*; public class TowerOfHanoiUsingStacks { public static int N; @SuppressWarnings("unchecked") public static Stack<Integer>[] tower = new Stack[4]; public static void main(String[] args) { Scanner scan = new Scanner(System.in); tower[1] = new Stack<Integer>(); tower[2] = new Stack<Integer>(); tower[3] = new Stack<Integer>(); System.out.print("Enter The Number Of Disks: "); int num = scan.nextInt(); N = num; toh(num); scan.close(); } /* Function to push disks into stack */ public static void toh(int n) { for (int d = n; d > 0; d--) tower[1].push(d); display(); move(n, 1, 2, 3); }

Java Tutorial For Beginners: Part 1.

Problem: Java Program To Print “Hello World” class HelloWorld { public static void main(String args []) { System.out.println("Hello Java");  }} Problem: Java Program To Calculate And Display Area Of A Circle import java.util.*; class CalculateCircleAreaExample { private static Scanner s; public static void main(String[] args) { double r, area, pi = 3.14; s = new Scanner(System.in); System.out.print("Enter The Value Of Radius: "); r = s.nextDouble(); area = pi * r * r; // area of circle = pi*r*r System.out.println("The Area Of Circle Of Radius "+r+" = "+area); }} Problem: Java Program To Print Current Date And Time import java.util.Calendar; public class GetCurrentDateTimeExample { public static void main(String[] args) { Calendar now = Calendar.getInstance(); System.out.println("Current Year: " + now.get(Calendar.YEAR)); System.out.println("Current Month: " + (n

Introduction To C++ Programming - Part 3.

Problem: A Simple Program To Find The Absolute Value Of An Integer. Method 1:  #include <iostream> using namespace std; int main() { int number; int abs_number; cout << "Enter an integer (positive or negative): " << endl; cin >> number; // Find the absolute value if(number >= 0) { abs_number = number; } else abs_number = -number; // Print out output cout << "The absolute value of " << number << " is " << abs_number; cout << endl; return 0; } Output: Enter an integer (positive or negative): -11 The absolute value of -11 is 11

Introduction To C++ Programming - Part 2.

if statement: #include <iostream> using namespace std; int main()  { int a, b; cout << "Enter first number: " << endl; cin >> a; cout << "Enter second number: " << endl; cin >> b; if(a < b) cout << "First number is less than second.\n"; return 0; } Output: Enter first number: 5 Enter second number: 7 First number is less than second. if-else statement: #include <iostream> using namespace std; int main()  { int a, b; cout << "Enter first number: " << endl; cin >> a; cout << "Enter second number: " << endl; cin >> b;