Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
UMKD SDP2 2016-2017.docx
Скачиваний:
25
Добавлен:
14.10.2016
Размер:
126.72 Кб
Скачать

6. Methodological guidelines for tsis

Instructions

  1. Use the word processor on the computer to fill in this assessment.

  2. Start by inserting your name in the space above.

  3. Before you begin answering these questions, save this file using the require file name format: “<YourAndrewID> Quiz01.doc” where <YourAndrewID> is your AndrewID and there is a blank between it at the Quiz01. When you are finished with the quiz, save the document again and then upload it to the LMS.

Assessment questions

  1. Convert the decimal value of 23 to binary. Show your work.

  2. Convert the binary value 001011010111 to decimal. Show your work.

  3. How many types of programming languages are there, and why do we call Java a “higher level” programming language?

  4. A class enables the programmer to encapsulate _________ and the ________ needed to manipulate that data into one package? (10 points)

  5. In Java, what is the difference between the “declaration of a variable” and the “assigning of a variable”?

  6. For each following expressions, specify the Java type and value that would be generated by the expression:

Assume “a” and “b” are integer variable of the Java type “int” and “c” and “d” are approximations of real values of java type “double” with the following values:

int a = 2;

int b = 5;

double c = 3.0;

double d = -2.0;

Expression

Type

Value

a + 1

b + 2.0

b / a

a + c

c / d

a % b

(double) a + b / 2

(int) c + d

a – ++b

b + 2 / a - 3

Instructions

1. Use the word processor on the computer to fill in this assessment.

2. Start by inserting your name in the space above.

3. Before you begin answering these questions, save this file using the require file name format: “<YourAndrewID> Quiz02.doc” where <YourAndrewID> is your AndrewID and there is a blank between it at the Quiz02. When you are finished with the quiz, save the document again and then upload it to the LMS.

ASSESSMENT QUESTIONS

1. What would the value of “data” be after this assignment statement was performed? Explain your answer.

int data = 5/4;

2. What would the value of “data” be after this assignment statement was performed? Explain your answer.

double data = 5/4;

3. What would the value of “data” be after this assignment statement was performed? Explain your answer.

double data = 5.0/4;

4. What would the value of “data” be after this assignment statement was performed? Explain your answer.

double data = 5.0/4.0;

5. Java allows you to assign an “int” value to a “float” or “double” variable. Why does it not allow you to assign a “float” or a “double” to an “int”?

INSTRUCTIONS

  1. Use the word processor on the computer to fill in this assessment.

  2. Start by inserting your name in the space above.

  3. Before you begin answering these questions, save this file using the require file name format: “<YourAndrewID> Quiz03.doc” where <YourAndrewID> is your AndrewID and there is a blank between it at the Quiz03. When you are finished with the quiz, save the document again and then upload it to the LMS.

ASSESSMENT QUESTIONS

  1. In the space provided, show what the output generate by performing the following Java statements would be.

intdata = 8;

System.out.print("The value <" + data);

System.out.print("> is an integer! ");

System.out.println("This value <2> is text. ");

System.out.println("The end.");

  1. In the space provided, show what the output generated by performing the following Java statements would be.

System.out.print("The answer is: ");

inta = 12;

intresult = a / 3 + 1;

System.out.println(result);

System.out.println("The end.");

  1. In the space provided, show what the output generated by performing the following Java statements would be.

System.out.print("The answer is: ");

inta = 5;

doubleresult = a / 2 + 1;

System.out.println(result);

System.out.println("The end.");

  1. 4. In the space provided, show what the output generated by performing the following Java statements would be.

System.out.print("The answer is: ");

String inputLine = "2 4 3 1";

Scanner inputScanner = newScanner(inputLine);

inta = inputScanner.nextInt();

intb = inputScanner.nextInt();

intc = inputScanner.nextInt();

intd = inputScanner.nextInt();

intresult = a + b * c – d;

System.out.println(b +" "+ a +" " + d +" " + c);

System.out.println(result);

System.out.println("The end.");

  1. In the space provided, show what the output generated by performing the following Java statements would be. The input is shown in green below.

Scanner keyboard = newScanner(System.in);

String inputLine = keyboard.nextLine();

Scanner inputScanner = newScanner(inputLine);

Doublea = inputScanner.nextDouble();

String b = inputScanner.nextLine();

System.out.println(a);

System.out.println(b);

  1. For each following expressions, specify the Java type and value that would be generated bye the expression:

Assume “a” and “b” are integer variable of the Java type “int” and “c” and “d” are approximations of real values of java type “double” with the following values:

int a = 3;

int b = 6;

double c = 5.5;

double d = -3.5;

Expression

Type

Value

a + b

b - 2.0

a / b

b / a

a % b

b % a

a + b / 4.0

(int) c + d

c + (int) d

c + b / 2 - d

INSTRUCTIONS

1. Use the word processor on the computer to fill in this assessment.

2. Start by inserting your name in the space above.

3. Before you begin answering these questions, save this file using the require file name format: “<YourAndrewID> Quiz04.doc” where <YourAndrewID> is your AndrewID and there is a blank between it at the Quiz04. When you are finished with the quiz, save the document again and then upload it to the LMS.

ASSESSMENT QUESTIONS

1. In the space provided, show what the following code would display:

String theLine = "1 2 3 5 7 8 12 13";

Scanner theLineReader = new Scanner(theLine);

int cntr = 0;

while (theLineReader.hasNextFloat()) {

float value = theLineReader.nextInt();

System.out.print(value + " ");

cntr++;

}

System.out.println();

System.out.println("cntr: " + cntr);

2. In the space provided below, write the Java code necessary to read some real numbers (float) from the file DataFile.txt.

The program must:

• Read the file, one number at a time.

• Properly handle a value that is not a number.

• Print each number as an output.

Соседние файлы в предмете Программирование на Java