CIS 111 Review
You should know how to....
- Declare a class
- Declare a variable (int, double, String, View)
- int i;
- double d = 10;
- String s = "";
- View v = new View();
- Declare an array
- double [] D = new double[20];
- int [] I = new int[x];
- Create a loop
- for(int i = 0; i < 10; i++){...}
- while(x < 10) {...}
- Preform mathematical expressions
- x = y + 7;
- x = n * 8 - 2;
- Create if statements
- if ( x == 8) {...}
- if (y > 9 ){...}
- Use Arrays
- a[i] = v.getInt("Enter...");
- a[i] = 10;
- if(a[i] > 4) {...}
Answer Key for the Midterm
CIS 111
MidTerm
Name_____Matt_______ 1 pt
Thursday; March 3, 2006
40 points
Please answer the following question's.
1)
Write the definition of a class called
Person.
5 pts
Write the main method for the class
Person
5 pts
public class Person
{
public static void main(String [] args)
{
}
}
2) Declare the following variables
a variable named "age" which can hold whole numbers
with a initial value of
10
3 pts
a variable named "time which can hold decimal
numbers with and initial value of 3.0 3
pts a variable named "name" which can hold a sequence
of letters 3 pts
int age = 10;
double time;
String name;
3)
Declare an instance of the View class and do the following:
read an whole number with the prompt "Please Enter the Age"
and store the value in a variable
named "age" which can store whole numbers 10 pts
View v = new View();
int age = v.getInt("Please Enter the Age");
4)
Use the View to print out the following "Matt is 25
years old" 10
pts
Use the variables name and age where
name = "Matt"
age = 25
v.print(name + " is " + age + " years old");