Archive for September, 2007
HW for 28/9 (Chater 4)
4.1
1 a) x=x * 2 (x*= 2)
b) y=y%2 (y%=2)
2 a) x += 5;( x =x +5)
b) x *=x ( x=x * x)
4.2
1 a)z=Math.sqrt(y)
z=2
b)z =Math.roud(x);
z=4
c)z=math.pow(y,3)
z=64
d)z= Math.round(Math.sqrt(x))
z=1
2 a) system.out.printl(generator,nextint (20)+1);
b) system.out.print(generator,nextdouble(10));
Add comment September 28, 2007
home Work for 9/20
3.1
1.)what is the Vocabulary of a language? Give an example of an item in the vocabulary of java.
Vocabulary is the set of all of the words and symbols in the language. example – assignment operator is =
2.) Give an example of a syntax rule in java
ex) in an expresstion, left and right parentheses must occur in matching pairs
3.) What does the expression ( x + y )* z mean ?
variable x plus variable y times variable z
4.) Describe two diffrencs between programming languages and
natural languages.
Programing languages have small vocabs and simple syntax and semantics compares to natural language. In a programing language one must get the syntax absolutely correct, wheres a grammatically incorrect English sentence is usually comprehensible.
3.2
1.double data type have a bigger storage requirment 8 bytes and a smaller range .Int data have a smaller storage requirment and a bigger range.
2. Java’s syntax for manipulating primitive data types differs distinctly from the syntax for manipulating objects. Primitive data types are combined in expressions involving operators, such as addition and multiplacation. Objects, on the other hand, are sent messages. in additionobjectts must be instatiated before use and there is no comparable requirment for prmative data types.
3.a 2.35 * 10
b 4.6 * 10^ -3
4.a 322100
b 0.0556
5. string “Worcester academy” or string “Nina”
6. a variable is an item whose value can change during the execution of a program.
7.bool a=false
double q=1.234
8. double payRate=35.67
9.int a,b,c=4
10.int q=1.324, or int w=hello
11.final double KILOGRAM=2.2
12.a)25 b)-3 c)30 d)0
13.a) there are more than one aritmetic operator in between the numbers
b) This equation lack of one left parenthesis.
c) there are no actual command in the bracket
14.a)2.25 b)0.4444 c)0
15.a) valid, because z is a less inclusive data type than x is.
b) valid, because z’s int data type will be autimatically converted to the more inclusive double data type. Since x is in the double data type, it will be valid for it to hold the result.
c)not valid ,since z is assigned to be in int data type, a less inclusive data type than double data type, so z can’t hole the result of x+y, a double data type.
16. a) (int)x*y=8 b)(int)x*y=9
17.y(int) x
18.a) y+x = WizardJava
b) y+y.length () + x = Java4Wizard
19.
20.to correspond, the method must have the same name as the message. Messafe are sometimes accopanied by parameters annd sometime not
21. double nextdouble( ) Returns a double entered by the user at the keyboard
void println (double n) Writes n to the print system
22.a)valid
b)valid
c)invalid
d)valid
e)invalid
23 a) diameter
b) constant
c) Retangle drawer
24. x is the overall name of the package
y is the name of a subsection within the package
z is thename of partcular class in the subsitution
25.That is the subsection that import all the classes
3.3
1a) System.out.print ” Enter your Wage (a double) : “) ;
wage = reader.nextDouble ( );
b) System.out.print “Enter your Social Security number (a string): “);
Social Security number = reader.nextLine
2.Returns the first interager in the input line. Leading and trailing apaces are lgmored.
3.
3.4
1.End of Comment: these include all of the test following a double slahsh (/) on amy given line, in other wrds, this style is best for just one line comment
Multilime comments: these include all of the test between an opening/* and a closing */
2. accompany a varibale declaration with a comment tath explains the variable purpose
Precede maprs segments of code woth brief comment that explains the variable’s purpose
Add comment September 24, 2007
Home Work for 9/13
Nina ’s birthday is tomorrow=)
Ex 2.1
1)Yields programs that can be run on diffrent types of program without change.
2)The two feature that Java have is enable the constructuon of virus fre, tamper-frree systems and suppport the development of programs that do not overwrite memory.
3) A thread is a process tjat cam run concurrently with oher processes. a single java might contain two thread. one thread transfer an image from onw machine to anther acrosss a network,while the other thread simultaneously interacts with the user.
2.2)
1) JVM stand for Java Virtual Machine
2)Byte code is the machine languare for an imaginary Java Computer.Java compiler translates Java not into a machine langage,but into bate code.
3) The small Java programs that were already translated into byte code in the web page that we downlode. Those were called applets. They are run in a JVM that is incorporated into the web browser.
2.4)
1. A program is a sequence of instructions for a computer.
2. it is the things you want to print in the terminal
3.you go to your terminal a type
System.out.println (” and put what you want it to do “);
4.public class HelloWorld {
public static void main(string [] args {
system.out.println(” Rita Tam “)
system.out.println(“81 Providence street 01604 “)
system.out.printlb(“617-314-1158 “)
}
}
2.5)
1.
Add comment September 13, 2007
Assignment on 9-11-07
1.)it is call a Byte Code
2.)C
3.) i will first check did i remember to put the HelloWorldApp class definition in the program excectly as what it was before (like does it Capitalize), Recheck can the the path class be found.
4.)The correct signature of the main method is Public Static Void Main (Sting[ ] args)
5.) It doest really have a main method,but the convention is public Statics
6.) The main method should be defines as a single parameter. It is usually named args, whose type is an array of String objects.
Exercise 1.
System.out.println(“Hola Mundo!”); //Display the string.
Add comment September 11, 2007
Home Work for 9/7
Q1. What is a bit in computer terminology? How many Bits in a Byte? How many bytes in a megabyte, and a Gigabyte?
1)a Bit is a short term for binary digit. It is the smallest unit of information on a computer.
eight adjacent bit = 1 Byte
100 Bytes = 1 megabyte
100000 bytes = 1 Gigabyte
Q2.Name 3 Computer input devices, 2 output devices.
2) kyboard,mouse,code reader is an input device
displace monitor,printers
Q3.What is a computer network?
3)A computer network is a data communacation system that interconnects computer at various different sites.
Q4.What is the difference between hardware and software?
4)Hardware consists of what you see on the destop Software consists of the program that give the hardware useful funcionality.
Q5.What is the difference between application software and system software?
5) application software deals with real life application, use to get work don.It is also easier to be understand by normal users.
system software keep all hardware and software running. It deals with the system and hardware.
6) What is machine language?
6. Machine language is the lowest-level of programing langue.It is a language that is only understood by the computers.It consists a bunch of numbers.
7)Name 5 Different programming languages
7.Machine language, Assembly language,high-level langage,java,JavaScrpit-a scripting language
8. What is the ACM code of ethics?
The ACM Code of Ethics is a set of guidelines that are intended to enhance the reputation of professionals practicing in a computing field, and to maintain the integrity of the field itself.
Add comment September 7, 2007
AP Computer class day 1
Today is the first class of my computer class. I have no clue what programing is.But i think i am already in love with this class and i think i will learn alot from this class =)
Add comment September 6, 2007
What do i think programming is ?
Actually i don’t really know what Programming is, but from what i see i am intrested in joining this class because i think programming could be fun. I think people put in a set of code in the conmputer and some how it become a program that works. I think programing could have many diffrent kinds. People could make a program for a company to help them block the people that will “hack” into their computer or make a program that will protect them from the computer viuris. That is all i know about programming.
Add comment September 6, 2007