there are 3 classes letterd, letteru, letterh. each class uses loops to print asterisks in the form of letter d, u, h. each letter has two charateristics width and height. the constructor of each class accepts two integer parameters that correspond to height and width. each class also has a method called toString which returns a string that contains all the characters needed to properly form the corresponding letter. the tester program testerduh which is available.. produces the following output where the height and width of each letter are seven characters. create a duhconsole class that asks the user to enter the width and height then prints duh using those dimensions. the dimensions must be odd numbers and must be a minimum of five characters.

class LetterD {
// Override toString() for Letter class.
private int width;
private int height;
LetterD(int w, int h){
width = w;
height = h;
public String toString(){
        String r = "";

        for(int i=1;i<=height;i++){
        for(int j=1;j<=(width-1);j++){
        for(int j=1;j<=(width-2);j++){
        r=r+" ";}
        return r;}}

so far i'm done with D but i can think how to make the U and H

public class TesterDUH {

public static void main(String args[]) {

    LetterD a = new LetterD(7,7);




and the runner code

This article has been dead for over six months. Start a new discussion instead.