Coder Social home page Coder Social logo

method-madness-homework's Introduction

title type creator competencies
Method Madness
homework
name city
Baseline curriciulum, adapted by James Traver
NYC/Chicago
Java, Methods

Method Madness Homework

Practice writing methods that return data and are void!

Get Started

  1. Fork this repository
  2. Clone it to your computer
  3. Open the project in IntelliJ
  4. Create a new src directory and create a Madness.java class inside of the project.

Inside of your Madness.java, you'll need to write various methods. These methods should be defined inside of your Madness class below your main method. Some of these will return data; some may not. Complete as many as you can until your eyes bleed and then push your changes (sync/publish/push) and then create a pull request to submit your homework.

Hint You may need to research the Math class for help with this assignment.

Method Madness: Part One

  1. Define a function maxOfTwoNumbers that takes two numbers as arguments and returns the largest of them. I would suggest using conditional statements. Do some Googling to figure this out if you forget how conditionals work.
  2. Define a function maxOfThree that takes three numbers as arguments and returns the largest of them.
  3. Write a function isCharacterAVowel that takes a character (i.e. a string of length 1) and returns true if it is a vowel, false otherwise.
  4. Write a function that return the number of arguments passed to the function when called.
  5. Define a function reverseString that computes the reversal of a string. For example, reverseString("jag testar") should return the string "ratset gaj".
  6. Write a function findLongestWord that takes an array of words and returns the length of the longest one.
  7. Write a function filterLongWords that takes an array of words and a number i and returns the array of words that are longer than i characters long.
  8. Create a class, Car, that has the following member variables: mTopSpeed and mNumberOfDoors. In that class, write a constructor method that assigns random values to the member variables. Also, write a method that prints out the line "Your car has the top speed of ___ mph, and for some reason has ____ doors."

Method Madness: Bonus

These are stretch goals; if you have time you should work on them! They are bonus.

  1. Write a function that takes in a number and returns true if the number is even or false if the number is odd. You may use control flow and multiple conditionals.
  2. Write a function that takes in two words and compares them. If the spelling is the same, the functions returns true, otherwise false.
  3. Write a function that takes in a word and prints out its every letter on a new line before it sees the letter "w". If it encounters "w" the function should stop executing.
  4. Write a function that generates a random number. Print it out. If the number is greater that 50, return it, otherwise return -1. You may use control flow and multiple conditionals.
  5. Write a function that takes in 3 integers: day, month, and year and computes day, month, and year of the next day. The function should return a string (e.g. day:12 month:11 year:1988)
  6. Write a function that takes in a word, omits every other letter in that word and returns a new word. You can use control flow and multiple conditionals.
  7. Write a function that takes in a number greater than 5 and prints out all the numbers from 1 to that number except number 4. Please use a while statement.
  8. Write a function that takes in 2 numbers, and checks if they are the same. If they are not the same, it adds 1 to every number and returns its sum. If the numbers are the same, it adds 2 to every number and returns its sum.
  9. Write a function that asks the user to enter a country domain. If the user types in "us", the function prints out "United States", if the user enters "de", the function prints out "Germany", if the user types in "hu" the response should be "Hungary". In all other cases the function should print out "Unknown". Please try to use a switch statement and make sure the function works with a user's input of lower and upper case strings.
  10. Write a function that asks the user to type in a letter and prints out whether the letter is a vowel or a consonant. You may use control flow and multiple conditionals.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.