Tuesday, June 30, 2009

intrprog blog june 30,2009

Today we had a new lesson in intrprog. Its about using Math.sqrt and Math.pow. I also found out that the site java.sun.com is very useful because it has API that can help us alot in programming.
So far i could still catch up with the lessons. But i'm really wondering why my codes are very long while some have very short codes. Because of this i think that i really have to learn how to minimize my codes.

Here's the activities i made...

import java.util.Scanner;
public class Abc
{
public static void main(String [] args)
{
System.out.println("Enter your name");
Scanner x= new Scanner(System.in);
String a=x.nextLine();

System.out.println("Enter 1st grade");
Scanner y= new Scanner(System.in);
double b=y.nextDouble();

System.out.println("Enter 2nd grade");
Scanner z= new Scanner(System.in);
double c=z.nextDouble();

System.out.println("Enter 3rd grade");
Scanner w= new Scanner(System.in);
double d=w.nextDouble();

double e = (b+c+d)/3.0;
System.out.println( a + ", your average score is:" + e);
}
}


import java.util.Scanner;
public class Abcde
{
public static void main(String [] args)
{
System.out.println("Enter a");
Scanner x= new Scanner(System.in);
double y=x.nextDouble();
double a= Math.pow(y,2);

System.out.println("Enter b");
int z=x.nextInt();
double b= Math.pow(z,2);

double w= a+b;
double c= Math.sqrt(w);

System.out.println("Letter c is " + c );
}
}

import java.util.Scanner;
public class Abcd
{
public static void main(String [] args)
{
System.out.println("Enter a");
Scanner x= new Scanner(System.in);
double y=x.nextDouble();
double a= Math.pow(y,2);

System.out.println("Enter b");
int z=x.nextInt();
double b= Math.pow(z,2);

double w= a+b;
double c= Math.sqrt(w);

System.out.println("Letter c is " + c );
}
}

Saturday, June 27, 2009

The Hello World


"hello world" was the first program that I did in intprog class.

its actually very simple

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

After writing that in the notepad, you have to type Hello.java .<-- i often forget this
the outcome of the screen must have a "Hello World" written on it.

note:
" " - is for strings
' ' - for char
true or false- Boolean
System.out.println- will be shown on the next line
System.out.print- will be on the same line

I learned that this is very important.. knowing the use of modulo and division.
given: n=12345

n/10=1234
n/100=123
n/1000=12
n/10000=1

n%10=5
n%100=45
n%1000=345
n%10000=2345

Honestly, this was very confusing and i didn't think that it was possible for a program to find the middle number in a given.Although the solution was given by our prof Mr.Inventado, I tried doing it.
so here's what i did

public class Mid
{
public static void main(String [] Args)
{
int n=12345;
int mid;
mid= (n/100)%10;
System.out.println ( " With the given number:" + n);
System.out.println ( " the middle number is: " + mid);
}
}
i also learned that % and / can also be used in converting military time to standard time.
Here's the solution from our intrprog prof , Mr. Inventatdo.

public class Time
{
public static void main(String [] Args)
{
int giv=1545;
int hr= giv/100%12;
int min= giv%100;
String zero= min<10? "0": " " ; System.out.println ( hr + " : " + zero + min);
}
}

lessons from intrpog

hi everyone, i created this blog so that i can share what i learned in our intrprog class.

Intrprg
Lesson
Lesson #1
Java
one thing that I can remember in java would be the acronyms WORA .
it means
W-write
O-once
R-run
A-anywhere
I was amaze that the java was named because of an Oak tree that stood outside their office.
Lesson #2
In learning java, there are three operations we must remember.
Arithmetic Operation
arithmetic is similar to math. It has addition , subtraction, division , multiplication and modulo division. See the next line.
+ , - , / , * , %
what differ is that in arithmetic operation and math, is that you have to use that given symbol in order for it to function. We can't use an "x" or a "point" for multiplication. It should be asterisk "*".
Relational Operations
Relational is comparing 2 numbers with the use of the operations. " > . < . == , != , ≥ ,≤"
and the outcome of that, true or false , is known as Boolean.
Logical Operations
Logical operations was similar to our lesson in physics and it was confusing.
but when our prof discussed it, i realized that it is only easy.
I learned 3 logical operations in out intprog,
|| -or
&&- and
!- not
|| - if one is true then all are true
&& - if one is false then all is false
! - the opposite
Lesson #3
How to make a flowchart.
I learned that in making a flowchart, each shaped has it own usage. A Terminal shape tells you where the flowchart begins and ends . A parallelogram is used to show input or output. The rectangle is used to show a process, task, or operation. A diamond shape is for the decision that commonly asks a question. And to complete the flowchart,we need lines with arrows to determine the flow through the chart

2 sites given by our prof that are useful in making flowcharts
  1. my.lovelycharts.com
  2. http://www.gliffy.com/