Tag Archives: String assignments

String Lab Assignment

In this lab, you will work with a GUI to validate the input in each text field . Below is a screenshot of the running program.  Download Source File

validate-user-input

Validate that each of the following criteria has been met.

  1. User’s name
    1.  at least 3 characters
    2. only upper and lower case letters allowed
  2. Password
    1. at least 4 characters
    2. cannot contain the user’s name
  3. Email
    1. Must include an “@”
    2. Must include a “.”
    3. the “.” must come after the “@”
  4. Phone
    1. XXX-XXX-XXXX
      1. where each”X” must be an integer value
      2. each “-” must be in the correct location
  5. Date of Birth
    1. Max age is 110
    2. Minimum accepted age is 18
      1. If the user is less than 18, display the message. “Sorry you must at least 18 years of age for this service”
  6. Zip Code
    1. Each character must be an integer
    2. Length between 3 and 5 , inclusive

 

 

screen-shot-code

 

 

A  file that does a few test cases (be careful not to overwrite your work)

Java String Project Bases and Decimals

Create a class called BaseMaster (spelled exactly like this)

 

//helper functions

the isNumeric() method returns true if every digit is an integer . It also allows for a single ‘.’ to represent a decimal point.

 

 

example call return value
isNumeric("3.1") true
isNumeric("3.1.1") false
isNumeric("3a") true (assume base 16)
 isNumeric("3D")  true (assume base 16)

To get A+, you need to make base10toOtherBase() support bases 2-10 AND base 16

Intro To Java Assignments (2013-14)

Arrays II

  • Arrays in Demo
  • Test : June 10th/11th (Arrays and two dimensional arrays)
  • Two Dimensional Arrays
  • The problem with Arrays
  • Array 2 (codingbat)  Do any 18 questions.  You can get extra credit for doing any of the last 4.  EOD Sunday  May 31st
    • All students must do sum67
  • Array Fun 2 (due by EOD Tuesday May 13rd )
  • Array Fun 1 (email to me by EOD Tuesday May 6th)

Arrays

  • short circuiting
  • Array 1 Coding Bat  type questions
  • default values of arrays
  • arrays in memory(value vs reference)
  • swapping values in an array without creating a new array like this coding bat problem–assuming you didn’t make a new array
  • Coding Bat : Array 1 (Thursday April 24th-that’s day of the 2nd class after the April break)
  • Short Circuiting

April 2nd

      • Test (April 2nd/3rd)
      • All coding bat warm up and String 1’s must be completed by then
      • Strings immutable, codingbat.com

 

 

Strings (the basics)

String Cheat Sheet



String str ="ABCDEFG"

String firstLetter = str.substring(0,1)

String firstTwoLetters = str.substring(0,2)

String lastLttr = str.substring(str.length() -1)

String last_2_lttrs = str.substring(str.length() -2 )

String middle_lttr = str.substring(str.length()/2 , str.length()/2 +1)
Unit 2

Extra credit: Looping over Strings

 

Unit I
Deadline the day you return from feb break

coding_bat_matrix


Midterm Quiz

*Wed/Thursday 21st/22nd

      • definitions:
        • pass by value
        • pass by reference
      • C++ memory usage (see last asssessment) . Yes, pretty much same questions with different numbers
      • floating point error
      • understand of whether the following data types are pass by value vs reference in Java
        • int
        • double
        • boolean