Assignment 4
Due Wednesday, January 24 at 9:20am on Canvas


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

  • Open up Eclipse.
  • Create a new project called Football containing a C++ file called football.cpp.
  • Put a block comment at the start of your program with your name and section information
  • Add the library and namespace information
  • Write a main function
  • 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 cout. Therefore, this should NOT be your cout statement:

cout << "The area of a professional football field is 57600 ft2";

  • How can you change the above cout statement to replace the number 57600 with the area variable?
  • Submit your program to Canvas when you are finished.


Assignment 4.2: About Me (10 pts)
  • Open up a new C++ project in Eclipse with a file named aboutMe.cpp.
  • Write your name and section info at the very top of the file by placing them inside of a multi-line comment, like so:
/**
* Your Name Here
* CIS 22A Section
*/
  • The objective of your program is to store some values in a variable and then print those values to the console. These values will represent your hopes and dreams for the future!
  • Now, declare 4 new variables at the top of your program
  1. One int
  2. Two chars
  3. One double
  • The integer variable will be used to store your student id
  • One character variable will be used to store the initial of your first name.
  • The other character variable will be used to store the initial of your last name.
  • The double will be used to store your target GPA for this quarter
  • Now, assign each of these variables a value.
  • Finally, print out the variables with 4 cout statements (one for each variable).
  • The output of your program must look identical to the following (except I should see your information instead of the values below):

My student id # is 55555
J is my first initial
P is my last initial
My target GPA is 4 for this quarter
  • When you are finished, and your output matches the example above, submit your aboutMe.cpp file to Canvas