Tag: Java

Design and implement a class called Box that contains instance data that represents the height, width, and depth of the box.

Design and implement a class called Box that contains instance data that represents the height, width, and depth of the box.

LANGUAGE: Java CHALLENGE: Design and implement a class called Box that contains instance data that represents the height, width, and depth of the box. These dimensions should be of a type that can represent linear measurements, including fractional ones. Also include a boolean variable called full as instance data that represents whether the box is […]

Read More

Design and implement a class called Car that contains instance data that represents the make, model, and year of the car

Design and implement a class called Car that contains instance data that represents the make, model, and year of the car

LANGUAGE: Java CHALLENGE: Design and implement a class called Car that contains instance data that represents the make, model, and year of the car (as a String, String and int value respectively). Define the Car constructor to initialize these values (in that order). Include getter and setter methods for all instance data, and a toString […]

Read More

Design and implement a class called Sphere that contains instance data that represents the sphere’s diameter.

Design and implement a class called Sphere that contains instance data that represents the sphere’s diameter.

LANGUAGE: Java CHALLENGE: Design and implement a class called Sphere that contains instance data that represents the sphere’s diameter. Define the Sphere constructor to accept and initialize the diameter, and include getter and setter methods for the diameter. Include methods calcVolume and calcSurfaceArea that calculate and return the volume and surface area of the sphere. […]

Read More

Write a method, getSecondLine, that is passed a String argument and that returns the second line, without its newline character.

Write a method, getSecondLine, that is passed a String argument and that returns the second line, without its newline character.

LANGUAGE: Java CHALLENGE: Write a method, getSecondLine, that is passed a String argument and that returns the second line, without its newline character. (Recall that lines are terminated with the “\n” character .) Assume that the argument contains at least two complete, newline-terminated lines.

Read More

Write a method, makeEmailAddress, that is passed two String arguments: the first is a username, like “leadbelly” and the second is a domain name, like “blues.com”.

Write a method, makeEmailAddress, that is passed two String arguments: the first is a username, like “leadbelly” and the second is a domain name, like “blues.com”.

LANGUAGE: Java CHALLENGE: Write a method, makeEmailAddress, that is passed two String arguments: the first is a username, like “leadbelly” and the second is a domain name, like “blues.com”. The method returns an email address formed from joining these with an “@”: “leadbelly@blues.com”.

Read More

Write a method, getEmailDomain, that is passed a String argument that is an email address and returns the domain name part. So if “mozart@salzberg.de” is passed, the method returns “salzberg.de”.

Write a method, getEmailDomain, that is passed a String argument that is an email address and returns the domain name part.  So if “mozart@salzberg.de” is passed, the method returns “salzberg.de”.

LANGUAGE: Java CHALLENGE: Write a method, getEmailDomain, that is passed a String argument that is an email address and returns the domain name part. So if “mozart@salzberg.de” is passed, the method returns “salzberg.de”. Assume that the argument will always be a correctly formatted email address.

Read More

Write a method, getEmailUserName, that is passed a String argument that is an email address and returns the user-name part.

Write a method, getEmailUserName, that is passed a String argument that is an email address and returns the user-name part.

LANGUAGE: Java CHALLENGE: Write a method, getEmailUserName, that is passed a String argument that is an email address and returns the user-name part. So if “mozart@salzberg.de” is passed, the method returns “mozart”. Assume that the argument will always be a correctly formatted email address.

Read More

Write a method, makeSubjectLine, that gets a String argument and returns the same String but with “Subject: ” in front of it. So if the argument is “Are you going to the show?” the method returns “Subject: Are you going to the show?”.

Write a method, makeSubjectLine, that gets a String argument and returns the same String but with “Subject: ” in front of it. So if the argument is “Are you going to the show?” the method returns “Subject: Are you going to the show?”.

LANGUAGE: Java CHALLENGE: Write a method, makeSubjectLine, that gets a String argument and returns the same String but with “Subject: ” in front of it. So if the argument is “Are you going to the show?” the method returns “Subject: Are you going to the show?”.

Read More