Beginner Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsOtherBeginner Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 20th, 2012, 09:47 PM
yoooogurt yoooogurt is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2012
Posts: 2 yoooogurt User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 27 m 41 sec
Reputation Power: 0
Unhappy Need help on my Homwork :( im totally new to this

i was asked to write a program that will display a diamond and a hollow diamond. It need to ask the user to input the size and character, which to form the diamond, and must use 3 methods.

• Public static int checkSize(String size) – This method will return 6 if size equals “short”, 12 if size equals “average”, 24 if size equals “tall”, or -1 otherwise. Be sure that the comparison is not case sensitive.
• Public static void displayDiamond (int size, char ch) – This method will display a diamond of height size constructed from pattern character ch.
• Public static void displayHollowDiamond (int size, char ch) – This method will display a hollow diamond of height size constructed from pattern character ch.

in main method i had to use a do-while loop also, until the user input "short","average","tall", for size of 6,12,24.

an output of "short" should look like ( "o"means space
oo*
o***o
*****
*****
o***o
oo*

oo*
o*oo*o
*oooo*
*oooo*
o*oo*
oo*

And here is what i have so far (ive only completed the hollow diamond and no idea what to do for the other 2 methods.)

import java.util.Scanner;

public class Diamonds
{
public static void main(String[] args)
{
Scanner kb = new Scanner(System.in);
String input;
do
{
System.out.print("enter diamond size (\"short\", \"average\", or \"tall\"): ");
input = kb.nextLine();
}while();
System.out.print("enter pattern character: ");
char character = kb.nextChar();
}
public static int checkSize(String size)
{
if(size!=
}
public static void displayDiamond(int size, char ch)
{
}
public static void displayHollowDiamond(int size, char ch)
{
int i, j, k, l;
for(i=1, i<=size; i++)
k = i<=size/2 ? 2*1-1 : 2*(size-i+1)-1;
j = (size-k)/2;
for(l=0; l<k; l++)
System.out.print(" ");
for(l=0; l<k; l++)
if(l==0 || l==k-1)
System.out.print(ch);
else
System.out.print(" ");
System.out.println();
}
}

any hint and helps??

Reply With Quote
  #2  
Old November 28th, 2012, 05:38 PM
Arikatoteshika Arikatoteshika is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2012
Location: Grand Rapids, MI 49508
Posts: 4 Arikatoteshika Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 56 m
Reputation Power: 0
I didn't get much of the project objectives but I think you can use this link: aisha91.hubpages.com/hub/Java-Source-Code-Recursive-Diamond-Shape-for-Asterisk
Comments on this post
Scorpions4ever disagrees: Why are you so ashamed of your country that you have to lie about being from Grand Rapids, MI. Why
not say you're from the Philippines?

Reply With Quote
Reply

Viewing: Dev Shed ForumsOtherBeginner Programming > Need help on my Homwork :( im totally new to this

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap