CompSci
  • Home
  •  Unit 1
    Output Exercises
     Unit 2
    Variables Math Modules Exercises
     Unit 3
    Conditionals Exercises
     Unit 4
    Iteration / Loops Exercises
     Unit 5
    Strings Exercises
     Unit 6
    Lists Exercises
     Unit 7
    Functions Exercises
  •  Unit 1
    Java Introduction Java Syntax Errors & Coding Conventions Format Method Exercises
     Unit 2
    Variable Introduction Math / Arithmetic Operators Obtaining a Value Formatting Numeric Output Concatenation & Constants Division & Type Casting Exercises
     Unit 3
    Conditionals Exercises
     Unit 4
    while Loops for Loops Exercises
     Unit 5
    Strings Exercises
     Unit 6
    Methods Method Parameters Method Return Types Exercises
  • Muddy City
  • Github Classroom
  •  Assignments
    Add an Assignment Edit Assignment Search Program Code
     Forum
    Ask a Question Search the Forum
     New Account
    New Account


Account Mgmt
Reset Password

Java - Methods


Exercises

House

Difficulty: Low

Title: House

Description:
Create a House application that calls methods:

  • addRoof()
  • addBase()
  • addWalk()
These three methods when combined should display a House similar to the one below:

Output:
Java House


Is Prime

Difficulty: Low

Title: Is Prime

Description:
Modify the Prime Number application created in the conditional exercises to include:

  • A method named isPrime().
  • The isPrime() method should require one parameter and return a Boolean value.
  • The main method would print whether a number is prime or not prime based upon the Boolean value returned.

Output:
Enter a number: 2
Prime


Enter a number: 12
Not Prime
Enter a number: 17
Prime



Computer Science