Category Archives: Computer Science

RPN Calc Assignment

Use A Stack Class to create a RPN calculator

Part I : RPN Math Class

Input: String representing RPN syntax

Parse the String  (Maybe a separate method)

Calculate the return value of the RPN syntax.

Examples of Syntax

  • “3 -5 * “ -15

 

IF invalid syntax is entered, your method should throw an ArrithmeticException

Things to Support

  • negative numbers (vs subtraction)
  • decimal points
  • multiple spaces between characters

Part II: The GUI

  • Numbers 0-9
  • negative
  • 5 operators
  • Enter button
  • Clear button
  • System.exit(0) button
  • ** EC: support for keypresses including enter

Part III: **EC : Infix to postfix (allow users to enter numbers in infix)

 

Send me the jar file.

Intro to CS 2015-16

Intro to CS 2015-16

Alice Unit 1

  • 1) Complete packets #3- 8  by Wednesday the 24th
  • 2) Assignment #1, Due Friday October 3rd
    • at least 10 instructions
    • modify a ‘subpart’
    • 1 do-together statement
    • at least 3 different objects
    • Worth 7 points.
    • To get a 7/7 you must achieve the ‘wow factor’–ie go above and beyond to create a superior final project
  • Quiz: TBA
    • binary number systems (see dropbox notes for review)
    • converting from various bases to base 10 (see dropbox notes for review)
    • comment vs instruction in Alice

Last  year’s class

Bank Runner Class

Bank Class

This is a modified version of this bank assignment

The responsibilities of this class are to

  • Methods
    • Person[] topAccountOwners(int number )
      • this method returns the  top number  owners with the greatest amount of cash in 1 account
    • ** boolean binarySearch( int accountNumber)  // this method should implement the binary search algorithm to determine if the account acct exists . Note for binary search to work, what must be true?
    • ** extra credit  Account[] sortByAccountId()
      •   this method returns an array of Accounts sorted by amount in the account

 

 

Compiled and Interpreted Languages

Comilers and Interpreters

Retrieved from http://en.wikibooks.org/wiki/Introduction_to_Programming_Languages/Interpreted_Programs

Retrieved from http://en.wikibooks.org/wiki/Introduction_to_Programming_Languages/Interpreted_Programs

java-compiler-interpreter

retrieved from http://www.greenteapress.com/thinkapjava/html/thinkjava003.html

 

compiler_interpreter

retrieved from http://www.pasteur.fr/formation/infobio/python/ch05s02.html

 

Playlist Project [Array]

A PlayList project will be based on Three Classes

The Artist class will store core information about an artist

The Song class will store basic information about a music song

The PlayList class will manage lists of songs and artists


 

Artist

  • Constructor(s) :
    public Artist( String name) { //missing code }

 

  • Instance Variables (“global” variables)

 

Methods

 


 

Song

Constructor(s):

Instance Variables

example of how to get current milliseconds as a long

Method

 


 

Artist

Song

PlayList


 

PlayList

  • Instance Variables
    • private String listName : This is the ‘name’ of your playList
    • private Song[] songs;
    • private  int[] stars ; //how many stars each song has between 0 and 5 inclusive.
    • Note: songs and stars are parallel Arrays
  • Constructor
    • public PlayList(String name) : There should be only 1 constructor that takes a parameter representing the name of the playList
  • Accessor Methods
    • public double averageRating() // returns the average star rating for the list
    • public double averageRating(Artist artist)  // returns the mean star rating associated with artist
    • public Song[] getSongs(Artist artist) // returns an array populated by the songs of the parameter artist
    • public Song[] getSongs() // returns all the songs in the list

    Mutator Methods

    • public void swap(Song song1 ,  Song song2 )  // switches positions of these two (maintain parallelism!)
    • public void  add(Song song , int stars)
    • public void removeSong(Song song, String artist )  //removes song associated with artist
      • Note: Be careful here. You are allowed to add the same song and artist. Duplicates are allowed.
    • public void removeArtist(Artist artist ) //removes all elements associated with artist
    • public void removeLowStars(int cutOff) //removes all elements associated with a star rating less than cutOff
    •  ** public PlayList sortByDate() //this returns a rearranged PlayList based on each Song’s date
    • ** public PlayList sortByRating() //this returns a rearranged playlist so that the 5 starred elements are the first group in the list, 4 stars second …1 stars, last
    • ** public PlayList shuffle() //this returns a new PlayList in which all of the songs have been reordered randomly.

Artist

Song

PlayList