Assignment 4
Due Tuesday, January 23 at 11:20am on Canvas

Assignment 4.1: My Student Information (10 pts)

  • Open up a new Java project in Eclipse.
  • Name the project Student
  • Add a new class to your project also named Student
  • Inside of Student.java, write your name and section info at the very top of the file by placing them inside of a multi-line comment, like so:
/**
* @author Your Name Here
* CIS 36A
*/
  • The objective of your program is to store some values in a variable and then print those values to the console.
  • Now, declare 5 new variables at the top of your program
  1. One integer
  2. Two chars
  3. One double
  4. One boolean
  • The integer variable will be used to store your student ID number. Give it an appropriate name of your choice.
  • The char variable will be used to store the first initial of your first name. Give it an appropriate name of your choice.
  • The other char variable will be used to store the first initial of your last name. Give it an appropriate name of your choice.
  • The double variable will be used to store your GPA. Give it an appropriate name of your choice.
  • The boolean variable will be used to store whether you plan to graduate in 2017.
  • Next, assign the correct value to each of these variables. You many do this on the same line in which you declared the variables, or on a separate line.
  • For example, you might have a statement that looks like this:

int id = 555999;

  • Or, you might have 2 statements that look like this:

int id;
id = 555999;
  • Both options are correct.
  • Next, you will print out the contents of these variables using System.out.print() statements.
  • You need one System.out.println statement per variable.
  • statement 1 should say: My student id #: <your student id here>
  • statement 2 should say: My initials are: <your initials here>
  • statement 3 should say: My GPA is: <your GPA here>
  • statement 4 should say: I will graduate in 2018: <true or false here>
  • Thus, when your program is run, the output should be identical to the following (except your information will be below, not my sample information):
My student id #: 5559999
My initials are: JP
My GPA is: 3.5
I will graduate in 2018: true
  • When you are finished, and your output is identical to the sample output above (but with your information, not mine), submit the Student.java file to Canvas.
  • Reminder: Look under workspace -> Student -> src  -> Student.java


Assignment 4.2: Area of a Football Field (10 pts)

  • Open up Eclipse.
  • Create a new Java file called Football with a class called Football.
  • Put a block comment at the start of your program with your name and section information (@author)
  • Write your main method
  • Declare a variable called length and assign it the value 360 (pro football fields are 360 feet in length)
  • Declare a variable called width and assign it the value 160 (pro football fields are 160 feet in length)
  • Declare a variable called area and assign it the value of length * width;
  • Run the program and verify that there are no errors.
  • Is this program satisfactory?
  • Now, alter the program to print out the value of the area
  • You should print out the area with the following message:

The area of a professional football field is 57600 ft2

  • Note that you want to print out the area variable inside your print statement. Therefore, this should NOT be your print statement:

System.out.println("The area of a professional football field is 57600 ft2"); <--don't do this!!!

  • How can you change the above print statement to replace the number 57600 with the area variable?
  • Submit your program to Canvas when you are finished.
  • Reminder: Look under workspace -> Football -> src  -> Football.java