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 );
}
}
Tuesday, June 30, 2009
Subscribe to:
Post Comments (Atom)
It doesn't matter if your codes are longer, it's more readable that way and easier to understand and modify in the future hehe :) {1 ORP} for you :)
ReplyDeleteok po, thanks.
ReplyDelete