Colorado State University

CS160: Foundations in Programming: Spring 2015


Recitation R3 - Simple Java Program



To be completed during your lab on Feb. 2-4, due date is Feb. 4 at 11:59pm.

You can use the Internet and past assignments and labs, but no help from any other human being. Any and all questions must be directed to your TA or your TA's helper during the lab.

Here are the instructions for the Java program:

Setup:

  1. Create a project called R3 in Eclipse.
  2. Create a class called R3 in the project R3.

    Follow steps A-J below, writing code in the main method that prints exactly one line per step. Comments may be helpful to document which step you are working on. If you cannot do a step, add an empty print statement in place of the code you cannot implement, for example System.out.println();. Do not print anything except what is specified below. Any extra output, including white space, will cause you to lose points. Your program should have exactly 10 lines of output.

    IMPORTANT: Do the steps in order and make sure that each step produces exactly one line of output!
    A) Print the string literal "Simple Java Program!"
    B) Print a string literal with exactly 12 characters (remember: that includes whitespace).
    C) Print a string literal with exactly 12 characters and is in ALL CAPS.
    D) Print the string literal "Keep on truckin'", remembering the apostrophe at the end.
    E) Print a string literal that is a palindrome.
    F) Declare three variables (i,j,k) of type int, and set them to the values 12, 76, and 1278. Print the integer values in the same order, separated by commas (','), with no white space.
    G) Declare three variables (x,y,z) of type double, and set them to the values 34.55, 1.2394857, and 239874.43. Print the double values in the same order, separated by colons (':'), with no white space.
    H) Print the value of the expression that adds the product of i and j to k.
    I) Print the value of the expression that divides x minus y by z.
    J) Print the value of the expression Math.sqrt((i * x) + (j * y) * (k * z)).

  3. Make sure your R3.java compiles and produces the correct output.
  4. Check your R3.java using the Checkin tab on the course website.
  5. Automated grading will be running throughout the lab until the due date.
  6. Each step counts for 10 points.
  7. You may leave the lab after completing the quiz.

You must submit your R3.java program using the Checkin tab on the course website.
© 2015 CS160 Colorado State University. All Rights Reserved.