Saturday, June 4, 2011

How to Hack WebAssign's Watch It

If you use WebAssign, sometimes they give you the button to the "Watch It" which are very helpful. However, you might be able to find the watch it to more than just the problems they give you..

If the URL looks like:
http://www.cengage.com/physics/book_content/1439048622_serway/SerPSE8e_w_player/SerPSE8e_21_033.html

or

http://www.webassign.net/v4cgi/extra/bc_enhanced/index.tpl?asset=watch_it_player&asset_url=/bc_enhanced/SerPSE8_w_player/SerPSE8_25_033.html&UserPass=

Change the URL "SerPSE8_21_033.html"
The "21" is the "chapter" and then the "33" is the "problem number".

Monday, May 30, 2011

How to write HelloWorld in C?


HelloWorld.c

#include <stdio.h>
int main() {
  printf("Hello world!\n");
}

HelloWorld in C++


HelloWorld.cpp

#include <iostream>

using namespace std;

int main() {
cout << "HelloWorld" << endl;
return 0;
}

HelloWorld in Java

For a pure Java HelloWorld:

HelloWorld.java

public class HelloWorld {
 public static void main(String[] args) {
  System.out.println("HelloWorld");
 }
}

javac HellWorld.java

java HelloWorld

HelloWorld in Android

1) Download Eclipse IDE: http://www.eclipse.org/downloads/
2) Download Android SDK for Eclipse: http://developer.android.com/sdk/index.html
-Installing Setup: http://developer.android.com/sdk/installing.html
3) Beginning Tutorial: http://developer.android.com/resources/tutorials/hello-world.html


HelloWorld.java
location: HelloWorld > src > com.HelloWord > HelloWorld.java
package com.HelloWorld;

import android.app.Activity;
import android.os.Bundle;

public class Hello extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
    }

}

main.xml

location: HelloWorld > res > layout > main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
<TextView  
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:text="@string/hello"
    />
</LinearLayout>

strings.xml

location: HelloWorld > res > values > strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="hello">Hello World, Hello!</string>
    <string name="app_name">HelloWorld</string>
</resources>

AndroidManifest.xml

location: HelloWorld > AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.HelloWorld"
      android:versionCode="1"
      android:versionName="1.0">
    <uses-sdk android:minSdkVersion="3" />

    <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".Hello"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

    </application>
</manifest>


Notice: "System.out.println("HelloWorld!");" is not being used because "HelloWorld" is a string pulled from "strings.xml" which is used in the "main.xml"