Assignment 1

Due Thursday, January 10 at 11:59pm on Canvas.


Optional: Install Eclipse on your home computer or laptop following the tutorial. If you run into problems visit me during office hours for one-on-one help. Eclipse will be required for all programming assignments in this class.

Assignment 1.1: Syllabus and Website Treasure Hunt (10 pts)


Assignment 1.2: Post a Clear Headshot Photo of Yourself on Your Canvas Profile (10 pts)
  • Go to "Account" -> "Profile" -> Click on the photo and upload a new photo
  • Please select a photo that is a close up photo of your face to receive full credit.
  • The goal of this assignment is to help me learn your names. If I cannot see your face clearly, the photo will not be helpful.
  • Because the images on my course list are so small, this photo needs to be of your face only -- not your face and shoulders or your face and body -- or the image of your face will be too tiny for me to recognize.

For example:

Close Up Photo of Face would receive full credit (10/10)
Photo of face only (Albert Einstein)

Photo of face and shoulders would receive partial credit (7/10)

Photo of face and shoulders (Albert Einstein)

Photo of face and body would receive half credit (5/10)



  • Please do not upload a photo that is not of you or you will receive no credit for this assignment
  • Half credit for a photo of your face and body or if I cannot clearly see your face in the tiny image next to your name on my course list.
  • No credit if I cannot see your face.
  • No credit for a photo that I consider to be inappropriate for an academic or professional setting.
  • Feel free to make use of photo editing software to crop your photo. Visit the de Anza computer lab for help using photo editing software.


Assignment 1.3: Pair Programming Fundamentals (10 pts)


Pair Programming Extra Credit Opportunity (1 pt)
  • Both partners fill in, sign, date, and submit the pair programming contract
  • Upload the document(s) along with your Assignment 1.4 to Canvas.
  • Only ONE partner submits Assignment 1.4 on Canvas. Please make sure both your names are on the files.

Assignment 1.4: Customer Data - Area Codes (10 pts)
  • Assume you work for a company that tracks customer information, including name, gender and phone numbers
  • Your company has a file called customers.txt which contains the following information:
Jiming Wu
F
4082123458
James Brown
M
8315678432
Leanna Perez
F
4087654433
Xing Li
M
8313214555
Stacey Cahill
O
8312123333
Mohammed Abbas
M
4083134444
Kumari Chakrabarti
F
4086667777
Shakil Smith
M
4082123333
Jung Ahrin
F
8319257788
Pedro Martinez
M
4086162323
Ally Gu
O
4089256776
Tamara White
F
8317778978
Alvin Ngo
M
4089256677
Abir Fadel
M
8316645325
Brad Feinman
M
8312023443
Xiaohang Yue
M
8318990033
  • Half of the 16 customers in this file have a phone number with an 831 area code.
  • Half have a phone numbers have a 408 area code.
  • Write a program that reads in all of the customer information using a loop, and stores the names of the customers in two different string arrays - each array of length 8.
  • One array should store the customers with a 408 area code and one array should store the customers with an 831 area code.
  • Hint: Use substring() to determine the area code of the customer's phone number.
  • When the customers are stored in each array, they should be stored as Mr., Ms. or Mx. depending on the gender below their name in the file.
  • In other words, whenever the customers.txt file contains an M below the customer name, you should place the word Mr. before the name.
  • Whenever the customers.txt file contains an F below the customer name, you should place the word Ms. before the name.
  • Finally, whenever the file contains an O below the customer name, you should place the word Mx. before the name.
  • You must also capitalize each name by calling the capitalizeName method.
  • I recommend calling capitalizeName before storing the name inside the array.
  • Finally, you will be required to write the two arrays to a file.
  • Each array should be written to a different file.
  • The 408 area code array should be written to a file called SJCustomers.txt
  • The 831 area code array should be written to a file called SCCustomers.txt
  • You must write the arrays to the file by calling the printArray method.
  • Note that you will need to call printArray twice - once for each array.
Method requirements
  • capitalizeName Method:
    • The method is named capitalizeName

    • It take in an array of Strings

    • It capitalizes all of the letters in each String of the array

    • This method must use a for loop. It cannot call any outside methods that we have not discussed in this class.

    • It returns nothing.

  • printArray Method:
    • The method is named printArray
    • It throws IOException
    • It takes in two parameters:
      •  the first parameter is an array of Strings,
      • the second parameter is a String for the name of a text file in which to write out the data
    • The method must open the file whose name is passed in as a parameter
    • It declares a PrintWriter and uses it to write to the specified file
    • It uses a for loop to print out the contents of the array in the file, with each element on its own line
    • It then closes the PrintWriter.
    • It returns nothing.
  • On the final, you will be required to write a the complete method, including its signature, and a Javadoc comment for each method
  • The method signature is provided below but will not be provided on the final.

  • Copy and paste the starter code below into a new class called AreaCodes.java

/*
 * @author
 * CIS 36A
 */
import java.io.*;
import java.util.Scanner;

public class AreaCodes {
    
    public static void main(String[] args) throws IOException {
        String name, gender, phone;
        //Declare your two arrays here - one per area code
        
        //Declare File and Scanner
        //Below variables to keep track of array index in loop
        int i = 0;
        int j = 0;
        while(??????) {
            //read in name and gender
            
            //if statements related to gender
            
            //read in phone
            
            //if statements for phone
            
        }
        //call capitalizeNames method twice
        
        //call printArray method twice
        //close Scanner
        
    }
   
          //write Javadoc comment here
    public static void capitalizeNames(String[] names) {
        return;
    }
   
          //write Javadoc comment here
    public static void printArray(String[] names, String fileName){//throw IOException
       return;
    }
}
  • Below is the output that your program should give inside of the SJCustomers.txt file
MS. JIMING WU
MS. LEANNA PEREZ
MR. MOHAMMED ABBAS
MS. KUMARI CHAKRABARTI
MR. SHAKIL SMITH
MR. PEDRO MARTINEZ
MX. ALLY GU
MR. ALVIN NGO

  • It should also give the below is the output in a second file called SCCustomers.txt file
MR. JAMES BROWN
MR. XING LI
MX. STACEY CAHILL
MS. JUNG AHRIN
MS. TAMARA WHITE
MR. ABIR FADEL
MR. BRAD FEINMAN
MR. XIAOHANG YUE