DOC PREVIEW
WVU CS 110 - Homework 1

This preview shows page 1 out of 2 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 2 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 2 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Homework 1, CS110Due February 3, 2006 (5 points per problem)Homework 1, CS110Due February 3, 2006 (5 points per problem)1. Given:int n=1, m=2, l=3;double x = 5.0, y = 4.0;Which of the following assignments are valid. If an assignment is not valid state the reason. If the assignment is valid show the result of the calculation.a. n = m = 5;b. x = 2 * n + 5.3;c. n = x % 5;d. x / y = x * y;e. x = x + 5;f. n = 3 + 4.6;2. Suppose x, y, z, and w are int variables. What value is assigned to each variable after the last statement executes?x = 5; z = 3;y = x – z;z = 2 * y + 3;w = x – 2 * y + z;z = w – x;w++;3. The following program has syntax mistakes. Indicate and Correct them. On each successive line, assume that any preceding error has been corrected.public class ProgWithErrorsA{public void main (String args[]) {final int PRIME = 11,213;final int RATE = 15.6;int i, x, y, w;x = 7;y = 3;x = x + w;PRIME = x + PRIME;system.out.println(PRIME);wages = rate * 36.75;system.out.println(“wages = “ wages);}4. Suppose a, b, and c are int variables and a = 5 and b = 6. What value is assigned to each variable after each statement executes? If a variable is undefined at a particular statementreport it as UND (undefined).a = (b++) + 3;c = 2 * a + (++b);b = 2 * (++c) – (a++);5. Write a program that prompts the user to input five decimal numbers. The program should then add the five numbers, and convert the sum to an integer and print the result.6. How does a variable of a primitive type differ from a reference


View Full Document

WVU CS 110 - Homework 1

Download Homework 1
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Homework 1 and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Homework 1 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?