Go Back   CodingForums.com > :: Server side development > Java and JSP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-26-2012, 09:34 PM   PM User | #1
Jemdt
New Coder

 
Join Date: May 2012
Posts: 29
Thanks: 2
Thanked 0 Times in 0 Posts
Jemdt is an unknown quantity at this point
Unsure how to answer a question

Hi,

In a book I've been reading, there's a section containing questions regarding the chapter. I'm fine with pretty much every single exercise par one, which involves thorough reading of the previous chapter - I've read through the chapter many times, but I've yet to find the answer. Here's the question:

1. Write a program that will print your initials to standard output in letters that are nine
lines tall. Each big letter should be made up of a bunch of *’s. For example, if your initials
were “DJE”, then the output would look something like:

(Nine line tall letter using asterixes)

It would be great if you could help.

Thanks,

James
Jemdt is offline   Reply With Quote
Old 06-26-2012, 11:39 PM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,741
Thanks: 4
Thanked 2,465 Times in 2,434 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
Print your initials, or print any initials provided?
Fou-Lu is offline   Reply With Quote
Old 06-27-2012, 08:48 PM   PM User | #3
Jemdt
New Coder

 
Join Date: May 2012
Posts: 29
Thanks: 2
Thanked 0 Times in 0 Posts
Jemdt is an unknown quantity at this point
Quote:
Originally Posted by Fou-Lu View Post
Print your initials, or print any initials provided?
Initials provided (you have to actually input your initials)

Sorry for the late reply
Jemdt is offline   Reply With Quote
Old 06-28-2012, 02:15 AM   PM User | #4
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,741
Thanks: 4
Thanked 2,465 Times in 2,434 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
This will be a tremendous task to do. Although it may be possible to make use of the GlyphVector class in some way, I haven't a clue of how it would be done. Unfortunately, graphics are far from my specialty. May even be able to make use of just the Graphics2D class to help on that too. Effectively, you'd map a pixel by pixel check of a Character and compare it to a matrix or array to fill it.

Barring that, since I haven't a clue if that's even doable, its manual. You start with:
  • Using a spreadsheet, block a 9x9 cell grid
  • Draw your representation of a character
  • Use the data there to populate a multidimensional array

I'd actually make a Matrix for it. Then it becomes quite easy since you can create a Vector<Matrix<Character>> as your datatype to collect the initials in, then use standard iteration to display it. Populate the Matrix with the location of the stars, then use the map to look up the inserted letter and add it to the vector. Iterating becomes easy since you can make use of % to determine which character you are evaluating.

I can't think of an easier solution. This is a heck of a task to map 9x9 to 26 characters.
Fou-Lu is offline   Reply With Quote
Old 06-28-2012, 07:04 PM   PM User | #5
Jemdt
New Coder

 
Join Date: May 2012
Posts: 29
Thanks: 2
Thanked 0 Times in 0 Posts
Jemdt is an unknown quantity at this point
Quote:
Originally Posted by Fou-Lu View Post
This will be a tremendous task to do. Although it may be possible to make use of the GlyphVector class in some way, I haven't a clue of how it would be done. Unfortunately, graphics are far from my specialty. May even be able to make use of just the Graphics2D class to help on that too. Effectively, you'd map a pixel by pixel check of a Character and compare it to a matrix or array to fill it.

Barring that, since I haven't a clue if that's even doable, its manual. You start with:
  • Using a spreadsheet, block a 9x9 cell grid
  • Draw your representation of a character
  • Use the data there to populate a multidimensional array

I'd actually make a Matrix for it. Then it becomes quite easy since you can create a Vector<Matrix<Character>> as your datatype to collect the initials in, then use standard iteration to display it. Populate the Matrix with the location of the stars, then use the map to look up the inserted letter and add it to the vector. Iterating becomes easy since you can make use of % to determine which character you are evaluating.

I can't think of an easier solution. This is a heck of a task to map 9x9 to 26 characters.
Thanks for the reply, but judging by the fact that this is only chapter 2 of a complete beginner's book, I'm presuming you'd make it via the use of a foreign subroutine, which is provided in the book (math.hws.edu/javanotes/source/TextIO.java).

Thanks for helping, if you could possibly skim through that it would be great.
Jemdt is offline   Reply With Quote
Old 06-29-2012, 05:38 PM   PM User | #6
Jemdt
New Coder

 
Join Date: May 2012
Posts: 29
Thanks: 2
Thanked 0 Times in 0 Posts
Jemdt is an unknown quantity at this point
Solved, thanks for helping, but it was actually an unbelievable fix and I'd actually happened to misinterpret the question (it pretty much involved lines of System.out.prints)
Jemdt is offline   Reply With Quote
Old 06-29-2012, 05:57 PM   PM User | #7
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,741
Thanks: 4
Thanked 2,465 Times in 2,434 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
That's great; I didn't have a chance to follow that link as I was out all evening yesterday.
If I were doing this and had extra time, I'd still do one for each character. If its entry level course, the ONLY way to approach that would be to use an char[][] assuming that datastructures haven't been covered (ie: you'd make a matrix otherwise). So manual c[5][8] = '*'; placement lol.
But it would sure look cool to take any initials and have it spit out.
Fou-Lu is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:07 AM.


Advertisement
Log in to turn off these ads.