12.07.2015 Views

last name, First name rrs class cs1500 Assignment name/number ...

last name, First name rrs class cs1500 Assignment name/number ...

last name, First name rrs class cs1500 Assignment name/number ...

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>last</strong> <strong>name</strong>, <strong>First</strong> <strong>name</strong><strong>class</strong><strong>Assignment</strong> <strong>name</strong>/<strong>number</strong>Date submittedcs-login<strong>rrs</strong><strong>cs1500</strong>Ex1Ancient Exam to give you flavor ofquestions.We may or may not cover the samematerial.Also my style has shifted.Total: 100 pts. No calculators anywhere in this course. No books and notes. Read the question first.Write clearly. If you need to write a program, include comments.x^n means x to the power of n.The space allocated below the question is designed to be sufficient for your answer.NOTE: Use back pages for scratch. Show all work on front pages. Good Luck.1. [12] Give two issues discussed on the policy page describing student behaviorissueHow to handle it correctly2. [12] List 4 different primitive data types in Java.For each data type, show an example of a valid value, and an example of operation.Primitive data type value Two valid operations onthis data type.(as an example) int -78 Two operations


3. [12] Judy wrote a Java program called “Grades”. She gave you the source code so you do notneed to write this <strong>class</strong>. The source code sits in directory hwk1 and you are already in thatdirectory.(a) What is the correct <strong>name</strong> for the source code file.(b) What are you going to type on the computer to compile this program.See the computer screen below.>>>>>>(c) What are you going to type on the computer to execute this program.See the computer screen below.>>>>>>


4. [12] Evaluate the following expressions using proper Java precedence of operations. Do not writethe program. Show the sequence of computation using parents to show what gets executed when, andstate the result the computer will come up with.For example: int p = 2 * 3 * 4;p = (2 * 3) * 4 = 6 * 4 = 24.what is p:p is 24int xx = 2 - 5 / 6 + 10 / 2;System.out.println(xx);//prints what?5. [12] Evaluate the following expressions using proper Java priority of operations. Do not write anyprogram. Show the sequence of computation and state the result.int ww = 10.5 - 2.0 * 3.0 / 10.0;System.out.println(ww);//prints what?


6. [12] What will this program segment print if anything.//inside some <strong>class</strong>public static void main(String[] args){int x = 3;int y = 4;int z = 5;if (x < y * z){System.out.println("monday");}else{System.out.println("tuesday");}}What will be printed if anything?//show what will be printed line by line if multiple lines are printed.7. [12] Consider the following code. What will be printed.//inside some <strong>class</strong>static public void main(String[] args){System.out.println("hello there");for (int k = 0; k < 10; k = k + 2){for (int m = 2; m < (k / 2); m = m + 1){System.out.println("m=" + m);}int x = 33;System.out.println("k=" + k);}}//show what will be printed line by line if multiple lines are printed.


8. [16] You were asked to write the complete Painter <strong>class</strong>.The program is used by a painter to figure out the cost of paint for painting your room, specifically, shewill paint all 4 walls of the rectangular room.The room has the following dimensions:width=3 meters, length=4.2 meters, height=2.5 meters. (no windows – you use it for meditation)One can of paint will cover area of 2 meter square.You must use variables for the above entities.Write a (single-method as we did many times) program that will compute how many cans of paint doesshe need to paint the room.Hint:Use the (6SP). (you don't have to show me every step – but think every step)As always, you are free to choose additional variables you need or that will make the program clear.I want to see some comments inside main telling what are you doing.//In real exam you will more space

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!