Friday, November 18, 2011

frog hops problem


Kermit, a frog hops in a particular way such that:

1. He hops 20cm in the first hop, 10cm in the second hop and 5cm in the third hop.
2. After three hops Kermit rests for a while and then again follows the same hopping pattern.

Calculate the total distance travelled by Kermit (in centimeters) for the provided number of hops. Exactly 4 numbers of hops will be provided to the program (one number per line) as per the below example.

Suppose the following number of hops is provided to the program:

4
6
3
5

Then the total distance covered should be displayed as follows:

55
70
35
65

Solution to Above Problem:


import java.util.Scanner;
public class problem1 {

public static void main(String[] args) {
int a,b,c,d;
Scanner in = new Scanner(System.in);
a = in.nextInt();
b = in.nextInt();
c = in.nextInt();
d = in.nextInt();
int[] array = {a,b,c,d};
int k = 0;

for(int i=0; i<array.length; i++){
int n = array[i];
int x = n/3;
int y = n%3;
int z = x*35;

switch(y){
case 0: k = 0 + z; break;
case 1: k = 20 + z; break;
case 2: k = 30 + z; break;
case 3: k = 35 + z; break;
}
System.out.println(k);
}
}
}

Java Conversion (From X type to Y type)


integer to String :
int i = 20;
String str = Integer.toString(i);
   or
String str = "" + i

double to String :
String str = Double.toString(i);

long to String :
String str = Long.toString(l);

float to String :
String str = Float.toString(f);


String to integer :
   str = "50";
   int i = Integer.parseInt(str);
   or
   int i = Integer.valueOf(str).intValue();

String to double :
Double d = Double.valueOf(str).doubleValue();

String to long :
   long l = Long.valueOf(str).longValue();
   or
   Long l = Long.parseLong(str);

String to float :
Float f = Float.valueOf(str).floatValue();

char to String:
String s = String.valueOf('c');


decimal to binary :
int i = 42;
String bin = Integer.toBinaryString(i);

decimal to hexadecimal :
 int i = 42;
 String hexstr = Integer.toString(i, 16);
  or
 String hexstr = Integer.toHexString(i);
   or
(with leading zeroes and uppercase)
   public class Hex {
     public static void main(String args[]){
       int i = 42;
       System.out.print
         (Integer.toHexString( 0x10000 | i).substring(1).toUpperCase());
     }
   }

hexadecimal (String) to integer :
int i = Integer.valueOf("B8DA3", 16).intValue();
   or
int i = Integer.parseInt("B8DA3", 16);
 
integer to ASCII code (byte):
char c = 'A';
int i  = (int) c; // i =  65 DECIMAL

To extract Ascii codes from a String
String test = "ABCD";
for ( int i = 0; i < test.length(); ++i ) {
   char c = test.charAt( i );
   int j = (int) c;
   System.out.println(j);
}

Note :To catch illegal number conversion, use the try/catch clause
Example to use try catch clause
try{
  i = Integer.parseInt(aString);
}
catch(NumberFormatException e) {
  .........
}

Saturday, November 5, 2011

Cloud Computing

What is Cloud Computing?
Business applications are moving to the cloud. It’s not just a fad—the shift from traditional software models to the Internet has steadily gained momentum over the last 10 years. Looking ahead, the next decade of cloud computing promises new ways to collaborate everywhere, through mobile devices.


The Cloud Computing buzz is growing every day with a growing number of businesses and government establishments opting for cloud computing based services.


These services are broadly divided into three categories: Infrastructure-as-a-Service (IaaS), Platform-as-a-Service (PaaS) and Software-as-a-Service (SaaS). The name cloud computing was inspired by the cloud symbol that's often used to represent the Internet in flowcharts and diagrams.


Best And Free Cloud Computing Application.



  • The Best Free Cloud Application to Manage your Money in the Cloud

Mint: A Cloud based personal finance tool to manage your money
                     [CloudMintManageMoneyOnline9.jpg]
  • Free Cloud based Desktop 

  1.  CloudMe:  Access, upload and share your files from anywhere, even your phone, truly represents what it does. Online storage, Photos, Music, Movies, Application development, Calendar, Mail, Media Player, Word Processors etc. It has both free and premium signup. It also offers a platform for web developers (Platform as a service, PaaS). The free account provides 3GB of CloudMe drive storage.          [FreeCloudBasedServiceApplicationiClo[1].jpg]
  2. Cloudo: A free computer that lives on the Internet, right in your web browser. This means that you can access your documents, photos, music, movies and all other files no matter where you are, from any computer or mobile phone. Cloudo is a hosted service, there is no hardware or software to setup and maintain, and the DDE is fully accessible from any internet connected device.

    [Free-Cloud-Based-Service-Application-Cloudo.jpg]
  3. eyeOS: It describes itself as the Open Source Cloud’s Web Desktop. I found it similar to the iCloud & Cloudo described above. It has a very attractive design, but as this is just an introduction, I am not providing any distinct comparison between these services. You should go and explore: Create an Account at eyeOS to get started with this free Cloud Desktop.
    [FreeCloudBasedServiceApplicationeyeO[2].png]

Friday, November 4, 2011

Free Web Hosting

Free Web Hosting 

I think this information can be useful for you. If you plan to get your website, here is one good free web hosting provider to choose  000webhost.

They provide hosting absolutely free, there is no catch. You get 1500 MB of disk space and 100 GB bandwidth. They also have cPanel control panel which is amazing and easy to use website builder. Moreover, there is no any kind of advertising on your pages.


You can register here: http://www.000webhost.com/514998.html

Thursday, March 24, 2011

StyleCop 4.4

StyleCop 4.4 Beta 1 is now available for download This release provides full support for C# and .net framework 4.0, and also provides integration into VS2010 and VS2008.
download link here
StyleCop 4.4 for VS2010 and VS2008


Saturday, March 5, 2011

How to find your facebook friend's location?

Where my friends be?
facebook friend's geographic location in google map.
Add your facebook account to WhereMyFriends website and then you can see your friend's location in google map.
good luck
website link
wheremyfriends

Thursday, March 3, 2011

How to add Meta keyword to your BlogSpot

First you need sign into your blogger account.
Then click the Design>Edit Html tab.
In that, you can see this line of code under <head> section
 <b: include data='blog' name='all-head-content'/>
Then you enter your Meta keywords below the above code of line.
Example of Meta tag
         <Meta content='DESCRIPTION' name='description'/>
         <Meta content='KEYWORDS' name='keywords'/>
         <Meta content='AUTHOR' name='author'/>
Replace the orange colors words with your appropriate contents.
You can also create your Meta tag from 

Then save template and publish your blogs.