Simple Calculator Program using Microsoft Visual Basic

Here is the output of our simple calculator:


Here's the code:

Dim a, b, r As Integer
Dim opr As String

Private Sub add_Click()
a = Val(Text.Text)
opr = "+"
Text.Text = ""
End Sub

Private Sub clear_Click()
Me.Text.Text = " "

End Sub

Private Sub divide_Click()
a = Val(Text.Text)
opr = "/"
Text.Text = ""
End Sub

Private Sub equals_Click()
b = Val(Text.Text)
Select Case opr
Case "+": Text.Text = a + b
Case "-": Text.Text = a - b
Case "*": Text.Text = a * b
Case "/": Text.Text = a / b
End Select
End Sub

Private Sub Form_Load()

End Sub

Private Sub multiply_Click()
a = Val(Text.Text)
opr = "*"
Text.Text = ""
End Sub

Private Sub subtract_Click()
a = Val(Text.Text)
opr = "-"
Text.Text = ""
End Sub


How to Add Social Icons on Blogger


Adding social icons on your site it's so easy just follow this steps.

Step 1: You can customize or select your own social icons any design  that you like you can visit this site for reference Click Me.

Step 2: After selecting the desired icon/design, If you have a photobucket account just simple go there and upload your photo/design icon to get the code.

Copy the DIRECT LINK only

Step 3:  Copy this code and replace the YOUR LINK HERE to your SITE or links you want to visit example, https://www.facebook.com/ and DIRECT LINK to your code on photobucket. 

<a href="YOUR LINK HERE"><img src="DIRECT LINK OF YOUR PHOTO" /></a>

<a href="YOUR LINK HERE"><img src="DIRECT LINK OF YOUR PHOTO" /></a>

<a href="YOUR LINK HERE"><img src="DIRECT LINK OF YOUR PHOTO" /></a>

<a href="YOUR LINK HERE"><img src="DIRECT LINK OF YOUR PHOTO" /></a>



Color Program

The user should input this following letter:

if Y the result should be YELLOW,  if R the result should be RED,  if W the result should be WHITE, if V the result should be VIOLET, if P the result should be PINK, if the user will input none of those letter ten the output should be "NO COLOR AVAILABLE!"

Code:


Here's the code:

package color;
import java.util.Scanner;

public class Color {
static Scanner console=new Scanner(System.in);
    public static void main(String[] args) {
       
         String input; char letter;
        System.out.println("Enter a letter:");
        input=console.next();
        letter=input.charAt(0);
        
        switch (letter){
            case'y':case'Y':System.out.println("Yellow");break;
            case'r':case'R':System.out.println("Red");break;
            case'w':case'W':System.out.println("White");break;
            case'v':case'V':System.out.println("Violet");break;
            case'p':case'P':System.out.println("Pink");break;    
            default:System.out.println("NO COLOR AVAILABLE!");break;      
        }
      
    }
}


ATM System

Problem: Create a program for a BANK called ATM SYSTEM
Transactions are:
- Balance Inquiry
- Withdraw
- Change Pin

NOTE: 

1.)  There will be 5 account holders
        - Name
        - Pin

2.) Ask for a transaction

3.) Perform the transaction

4.) Ask another transaction (Y/N) if  "Y" loop again

Code: 

package atm;
import java.util.Scanner;
public class Atm {
static Scanner candy = new Scanner (System.in);
public static void main(String[] args){

String name[] = {"Hatake Kakashi", "Uzumaki Naruto", "Oborume Shino", "Nara Shikamaru","Uchicha Sasuke"}; 
int pin[] = {1111, 2222, 3333, 4444, 5555}; 
double withdrawAmount, balance[]={10000.00,20000.00,50000.00,100000.00,1000000.00};
int account, results, choice, cpin = 0, oldpin = 0, newpin = 0;
String answer;
char choice1;


System.out.println("---AUTOMATED TELLER MACHINE---");
System.out.println("Enter your PIN number: ");
account =candy.nextInt();
results = pin (pin,account);
if(results==-1){
System.out.println("Invalid");
}
else{
if(pin[results]== account);}
do{ 
System.out.println("\n---[ WELCOME " + name[results]+"! ]---\n"); 
System.out.println(" -- TRANSACTION -- ");
System.out.println(" [1] Balance Inquiry ");
System.out.println(" [2] Withdraw ");
System.out.println(" [3] Change Pin ");
System.out.println("Enter Choice : ");
choice=candy.nextInt();

switch (choice){
case 1: System.out.println("\nYour Current Balance is "+balance[results]);
break; 

case 2: System.out.println("How much do you want to withdraw?");
System.out.print("Amount: ");
withdrawAmount=candy.nextInt();
if(withdrawAmount > balance[results]){
System.out.println("\nInsufficient funds in your accout");
}
else{
balance[results]-=withdrawAmount; 
System.out.println("\n Withdrawal Successful");
System.out.println("\n Your Balance is: " +balance[results]);
}break;

case 3: System.out.println("Enter Old Pin:\t\t"); 
oldpin=candy.nextInt();
System.out.println("Enter New Pin:\t\t");
newpin=candy.nextInt();
System.out.println("Confirm New Pin:\t");
cpin=candy.nextInt();
if ((oldpin== pin[results])&&(newpin== cpin)){
pin[results]=cpin;
System.out.println("\n PIN Changed");
} break;
default: System.out.println(" ERROR TRANSACTION !"); break;
}


System.out.println("*****************************");
System.out.println("You want another transaction?");
answer =candy.next();
choice1=answer.charAt(0);
}
while((choice1=='y')||(choice1=='Y'));
System.out.println("THANK YOU && COME AGAIN !!");
}

private static int pin(int[] pin, int account) {
for( int x=0; x<pin.length; x++){
if (account == pin[x]){
return x;
 }
   } return -1;
 }
}

What is Cloud Computing?

Cloud computing is the use of computing resources (hardware and software) that are delivered as a service over a network (typically the Internet). The name comes from the use of a cloud-shaped symbol as an abstraction for the complex infrastructure it contains in system diagrams. Cloud computing entrusts remote services with a user's data, software and computation.

There are many types of public cloud computing:

Infrastructure as a service (IaaS),
Platform as a service (PaaS),
Software as a service (SaaS)
Storage as a service (STaaS)
Security as a service (SECaaS)
Data as a service (DaaS)
Business process as a service (BPaaS)
Test environment as a service (TEaaS)
Desktop as a service (DaaS)
API as a service (APIaaS)


Fibonacci Method Turbo C

#include <stdio.h>
int main(void)
{
long f0=0, f1=1,n,temp,limit;
printf("Enter the limit number:");
scanf("%i",&limit);
printf("the fibonnacci number are:\n");
printf("1\n");
    for (n=2;n<=limit;++n) {
        temp=f1;
        f1+=f0;
        f0=temp;
printf("%i\n",f1);
    }
return 0;
}


How to Add Scroll bar when posting codes on Blogger

It's easy just follow this steps. Thanks to this blog who's helpful to me Click Me..I'm just re-posting it.
Go to >> POST after that go to>> EDIT HTML then paste this code below:
<pre class="alt2" dir="ltr" style="border: 1px inset ; margin: 0px; 
padding: 6px; overflow: auto; width: 640px; height: 114px;
 text-align: left;"><span><span style="color: rgb(0, 255, 255);">

After posting that code press >>COMPOSE and you can now start writing something on the box.




Adding even numbers (1-20)

Code:

package gene;
import java.util.Scanner;

public class Gene {
static Scanner console=new Scanner(System.in);
    public static void main(String[] args) {
    
        int sum=0;
        for(int i=0;i<=20;i++){
            if((i%2)==0){
            sum=i+sum;
        }
    
    
    }
System.out.println("sum = "+sum);
    }

}


Adding even numbers from 1-20 applying METHODS


This is our class work, the problem is to add even numbers from 1-20 using methods.


WITH RETURN TYPE WITH PARAMETER

package gene1;
import java.util.Scanner;
public class Gene1 {
static Scanner console=new Scanner(System.in);
    public static void main(String[] args) {
     
        int sum=0;
        System.out.println( "sum = " +Odd(sum) );
       }
 
    static int Odd(int x){
         for(int i=0;i<=20;i+=2){
           x=x+i;
     
    }
         return x;
}
 
}


WITH PARAMETER WITHOUT RETURN TYPE


package gene2;
import java.util.Scanner;
public class Gene2 {
static Scanner console=new Scanner (System.in);
    public static void main(String[] args) {
     
        int sum=0;
        Even(sum);
        }
 
    static void Even(int x){
         for(int i=0;i<=20;i+=2){
           x=x+i;
       

    }
         System.out.println("sum="+x);
    }
   
}

WITH RETURN TYPE WITHOUT PARAMETER
package gene3;
import java.util.Scanner;
public class Gene3 {
    static Scanner console=new Scanner(System.in);
    public static void main(String[] args) {
        
        Even();
        
    }
    private static int Even(){
        int x = 0;
        for(int i=0;i<=20;i+=2){
           x=x+i;
             System.out.println("sum = "+x);
         
    }
        return x;
}

}


Diamond (Nested for-loop)

Code:

package diamond;
public class Diamond {

    public static void main(String[] args) {
    for (int i = 1; i < 10; i += 2) {
    for (int j = 0; j < 9 - i / 2; j++)
 

    for (int j = 0; j < i; j++)
        System.out.print("*");

      System.out.print("\n");
    }

    for (int i = 7; i > 0; i -= 2) {
      for (int j = 0; j < 9 - i / 2; j++)
        System.out.print(" ");

      for (int j = 0; j < i; j++)
        System.out.print("*");

      System.out.print("\n");
    }
  }
}



THE OUTPUT:



Circle: Diameter,Circumference,Area

Problem: Write a Java Program that calculates and prints the diameter, circumference, or the area of a circle given the radius. The application should input a character corresponding the one of the three actions:
           
             D-  Diameter
             C-  Circumference
             A-  Area


CODE:

package circle;
import java.util.Scanner;

public class Circle {
    static Scanner gene=new Scanner(System.in);

    public static void main(String[] args) {
        char choice;
        String input;
        int rad;
        double ans;
   
        System.out.println("**PLEASE CHOOSE**");
        System.out.println("[D]iameter");
        System.out.println("[C]ircumference");
        System.out.println("[A]rea");
        System.out.println("Enter your Choice:");
        input=gene.next();
        choice=input.charAt(0);
        System.out.println("Enter the radius of the circle:");
        rad=gene.nextInt();
   
        switch(choice){
            case 'D': case 'd': System.out.println("Diameter");
             ans=2*rad;
            System.out.println("Answer:"+ans);
             break;

       
            case 'C': case 'c': System.out.println("Circumference");
            ans=2*3.14159265*rad;
            System.out.println("Answer:"+ans);
            break;

       
             case 'A': case 'a': System.out.println("Area");
             ans=3.14159265*rad*rad;
            System.out.println("Answer:"+ans);
            break;

default: System.out.println("INVALID INPUT");break;
 
             }

      }
}

   
   
 

Food Menu Program

Problem: Create a Java Program that uses Control Statements (must use switch-case statement and ladderized if-else ) that presents a menu of a fast food chain at least 5.

Consider the following:
a. The user of your program is the costumer.
b. The Costumer selects one menu.
c. Consider Discounts
         c.1  If the costumer is a Senior Citizen (give 20% Discount from the total amount due)
         c.2 If the costumer is a Student (give 5.5% Discount)
         c.3 If None of the (2) options No Discount will be given

Code
package oop;
import java.util.Scanner;
public class Oop {
    static Scanner gene=new Scanner(System.in);
    public static void main(String[] args) {
        String answer; char choose;
        do
        {
        int order,cash; double price=0,select,discount=0,total=0,fee=0;
        System.out.println("**OUR MENU**");
        System.out.println("[1] Burger and Fries           P100");
        System.out.println("[2] Cake and Ice Cream         P120");
        System.out.println("[3] Chicken and Rice with coke P150");
        System.out.println("[4] Special Palabok            P200");
        System.out.println("[5] Lechon Baboy               P300");
        System.out.println("\nEnter your order:");
        order=gene.nextInt();
        if((order>=1)&&(order<=5))
        {switch (order){
   
            case 1: System.out.println("\nBurger and Fries");
                    price=100;break;
            case 2: System.out.println("\nCake and Ice Cream");
                    price=120; break;
           
            case 3: System.out.println("\nChicken and Rice with Coke");
                    price=150; break;
           
            case 4: System.out.println("\nSpecial Palabok");
                     price=200;break;
               
            case 5: System.out.println("\nSpecial Palabok");
                       price=300;break;
                   
            default:System.out.println("none"); break;
        }
        System.out.println("[1]Senior\n[2]Student\n[3]None\n\nEnter your choice:");
          select=gene.nextInt();
          if(select==1)
              discount=price*.20;
         
          else if(select==2)
              discount=price*.15;
           
          else if(select==3)
              discount=0;
          total=price-discount;
          System.out.println("Enter your amount:");
          cash=gene.nextInt();
          fee=cash-total;
          System.out.println("\nDiscount="+discount+"\nAmount to pay="+price+"\nChange="+fee);
        }
        else
            System.out.println("invalid");
             System.out.println("\nDo you want to try again?");
        answer=gene.next();
        choose=answer.charAt(0);
        } while(choose=='y'||choose=='Y');
        System.out.println("Dumo-Arigatou");
     
   
    }
}


 
My IT Life © 2011-2014|Gene Rose