Printing out a diamond shape

I am in an intro Java course and the instructor asked us to write a program that prints out a diamond shape using the * symbol.
I have been racking my brain for hours and I cannot figure it out.
We must use the Scanner class.
Also, we only have been taught the:
if
if else if
while
do while
for
printf
and a very basic array
PLEASE HELP...THIS IS DUE THURSDAY!!!!

I am in an intro Java course and the instructor asked
us to write a program that prints out a diamond shape
using the * symbol.Okay.
So, ignore Java for the moment.
Break the problem down into pieces. I have to assume that you must have some idea on how to do some of it. If not, speak to your instructor.
How would you tell somebody to do it if you had to write down the directions, and that person was going to write it with pencil & paper?
That person doesn't know what a diamond is, and he will do exactly what you tell him, but you must make your instructions simple and precise. You can tell him in English, pseudocode, or a combination--whatever is easiest for you.
Do this first. If you can't do this, then you can't write it in Java.
Once you do that, work on translating those steps to Java.
I have been racking my brain for hours and I cannot
figure it out.What, precisely can't you figure out? There are several steps here (as you'll see when you do the above exercise). Which of them are giving you trouble? If you can't even write the steps, or can't translate any of them, then you need to speak to your instructor, or engage the services of a private tutor.
>
We must use the Scanner class.Okay.
Do you know how to use that class? Can you think of a step in your program where it might be useful?
Also, we only have been taught the:
if
if else if
while
do while
for
printf
and a very basic arrayYou don't need more than that. (Assuming you also know how to define classes, methods, and variables. You can't do anything in Java without that.)
PLEASE HELP...THIS IS DUE THURSDAY!!!!Okay. But nobody who's going to help you here cares about your deadline. Managing your time is entirely your issue. We'll help you with the technical stuff, on our own scheule.

Similar Messages

  • Trying to draw a diamond shape from a shape - Please help !!!

    Hi,
    I am trying to draw a diamond shape from a custom shapes library but having a hard time getting it to shape accurately, the shape I am trying to draw should look like this :
    If someone can teach me some photoshop techniques as to how to get all the angles reshaped accurately using some photoshop tools that will be great or if you can do it in my project file that will help too, the project psd file can be downloaded from here : http://tonyalepski.heliohost.org/Diamond.psd
    Your help would be really really appreciated.
    Thank you very much !!
    Tonya.

    Your diamond looked like it was square to me. So I centered your diamond over your canvas add a vertical  guide at 50%. Measured your square to be 190 PX  Dragged out a 190 PX square shape no fill 1 px red stroke.  Transformed the shape rotating it 45 degrees and moved it up to align with your diamond.   Dragged out a horizontal guide to match your diamond cut. Used the Pen tool to add two control points the square shape. and then use the pen tool to delete the top control point then convert control point tool to convert the two added control points.
    http://www.mouseprints.net/old/dpr/Diamond.psd

  • Drawing a diamond shape on a canvas

    I am trying to drw a diamond shape on a canvas in WPF
    the code is:
         public static void Diamond(Canvas canvas float Size, Point Position)
                PointCollection pointCollection = new PointCollection();
                Point Point1 = new Point();
                Point Point2 = new Point();
                Point Point3 = new Point();
                Point Point4 = new Point();
                PathFigure myPathFigure = new PathFigure();
                LineSegment myLineSegment = new LineSegment();
                PathSegmentCollection myPathSegmentCollection = new PathSegmentCollection();
                PathFigureCollection myPathFigureCollection = new PathFigureCollection();
                PathGeometry myPathGeometry = new PathGeometry();
                Path myPath = new Path();
                        Point1.X = Position.X + Size * 0.707F * 1.2F;
                        Point1.Y = Position.Y;
                        Point2.X = Position.X;
                        Point2.Y = Position.Y - Size * 0.707F * 1.2F;
                        Point3.X = Position.X - Size * 0.707F * 1.2F;
                        Point3.Y = Position.Y;
                        Point4.X = Position.X;
                        Point4.Y = Position.Y + Size * 0.707F * 1.2F;
                        myPathFigure.StartPoint = Point1;
                        myLineSegment.Point = Point2;
                        myPathSegmentCollection.Add(myLineSegment);
                        myLineSegment.Point = Point3;
                        myPathSegmentCollection.Add(myLineSegment);
                        myLineSegment.Point = Point4;
                        myPathSegmentCollection.Add(myLineSegment);
                        myPathFigure.Segments = myPathSegmentCollection;
                        myPathFigureCollection.Add(myPathFigure);
                        myPathGeometry.Figures = myPathFigureCollection;
                        myPath.Stroke = Brushes.Black;
                        myPath.StrokeThickness = 4;
                        myPath.Data = myPathGeometry;
                        canvas.Children.Add(myPath);
    however when i use the code insted on getting the diamond only the first string point and last (POINT4)  nodes re connected by a line . I am  missing something obvious but what ?

    Hi Mike before you replied I worked out this alternative 
     public static void Diamond(Canvas canvas float Size, Point Position)
                Point Point1 = new Point();
                Point Point2 = new Point();
                Point Point3 = new Point();
                Point Point4 = new Point();
                PathFigure           myPathFigure           = new PathFigure();
                PathFigureCollection myPathFigureCollection = new PathFigureCollection();
                PathGeometry         myPathGeometry         = new PathGeometry();
                Path                 myPath                
    = new Path();
                        Point1.X = Position.X + Size * 0.707F * 1.2F;
                        Point1.Y = Position.Y;
                        Point2.X = Position.X;
                        Point2.Y = Position.Y - Size * 0.707F * 1.2F;
                        Point3.X = Position.X - Size * 0.707F * 1.2F;
                        Point3.Y = Position.Y;
                        Point4.X = Position.X;
                        Point4.Y = Position.Y + Size * 0.707F * 1.2F;
                        myPathFigure.StartPoint = Point1;
                        myPathFigure.Segments.Add(new LineSegment(Point2, true));
                        myPathFigure.Segments.Add(new LineSegment(Point3, true));
                        myPathFigure.Segments.Add(new LineSegment(Point4, true));
                        myPathFigureCollection.Add(myPathFigure);
                        myPathGeometry.Figures = myPathFigureCollection;
                        myPath.Stroke = Brushes.Black;
                        myPath.StrokeThickness = 4;
                        myPath.Data = myPathGeometry;
                        canvas.Children.Add(myPath);

  • Diamond shape looks HORRIBLE, how do you do it?

    I am trying to figure out how to draw a diamond shape but my plan is not working.
    I am drawing a basic square and filling it with a color, then going to "rotate" to turn it into a diamond.  The edges are SO rough.  Is there a better way to create shapes with angles and somehow keeping clean adges.
    Thank you!

    There is a diamond shape in the Custom Shapes library, try using that
    http://help.adobe.com/en_US/Photoshop/11.0/WS4B042C0D-6A0F-4133-B4AF-5C1304061D55a.html

  • How can I print out the file directory?

    Years ago, I could print out a list of files in a folder from the finder window. Is there now a workaround utility to do that? I don't want to use screen shots, as the directory is too long and would require several screen shots.  thx.

    http://hints.macworld.com/article.php?story=20060720174103802
    or
    http://reviews.cnet.com/8301-13727_7-20026446-263.html

  • How can I print out the graph I need only, without the controls and indicators?

    I'm doing some programming in LABVIEW. I need to print out only the graph, without the buttons, controls, indicators. I tried to look for such a function in LABVIEW, but in vain. How can I achieve the result I expect in my programming?

    Hi Fenny,
    you should use the report generation functions to create a report containing your graph image and print it.
    Take a look at the Sample Test Report.vi you find in the report examples of LV.
    Just look at the part of the diagram where it is used Append Control Image to report.vi (in the center of the report functions chain); a graph reference is wired to the Ctrl reference input ( to create a reference of your graph right click on it and select create reference).
    Let me know if you need more help,
    Alberto

  • How can I print out the contents of my hardrive

    I have a hardrive with about 200 video clips and need to print the titles for cross refrerencing. I was just going to "grab" screenshots but this will take about ten sheets of paper. How can I print out a list of all the files on the drive?

    I tried this Finder drag method & discovered that it is very important to set the blank TextEdit document to plain text before the drag (from the format menu or with Cmd-shift-t). If you don't, TextEdit attempts to load the content of the files!
    Once I discovered this, I tried the method with Find (Cmd-F) results & it works for that, too. This means that by choosing the right combination of search location(s) & search criteria, you can extend the method to filter the list to just about any files you want, which could be very handy.
    For instance, set the "Kind" criteria to "QuickTime Movie" & location to "Computer" & you get a list of every QT movie. Or set the search location to the folder containing the movies of interest & you get all of them, including ones in subfolders. You could also use the 'date created' or other search criteria to filter the list to a specific subset of movies (or whatever).
    If you need to do this often, you could create one or more 'Smart Folders' with the criteria preloaded for each search.
    The only drawback I see for either Finder based method is the full path one. If you are getting results from just one or a few folders, Find & Replace can delete any of the path name fairly easily, but it becomes a chore if there are a lot of different ones. Some other text editor, like TexEdit Pro, that supports grep searches would be handy here, but since I'm not up to speed on grep, someone else will have to explain how to use it for this, if they want.

  • How can i print out the waveform chart?

      hello everybody,
    how can i print out the "waveform chart". can i do it just push the button. ( example; stop button is stop the program etc..)
    i checked the NI examples but i can't understand. i'm new to the Labview.
    pls help me.
    i added the my program
    look forward your reply
    regards from turkey...
    Message Edited by hknmkt on 05-29-2008 04:15 AM
    Attachments:
    29.05.2008_11.vi ‏37 KB

        hi jim,
    i tried the program but it's not running. When i run the program, it's print out without run the program
    i added the printed file.
    look forward your reply
    hakan
    Attachments:
    error8.JPG ‏8 KB

  • PO print out of delivery schedule

    Hi,
    Suppose I am generating a PO , in some cases I will be giving delivery schedule for some items in item details.
    I want this to come in the print out.
    But its not coming .
    Please advise.
    regards,

    Hi
    You can include logic with the help of Developre, If information is there in EKET for Purchase order ask him to include in print.
    regards
    Srinivas

  • How to print out wallet size photos on 6510 e-all-in-one series photosmart printer

    want to print out wallet size photos (size 3 and a half x 2 and a half).  I have windows XP and my printer is the photosmart 6510 e-all-in-one series

    You will have to change the settings in the photo editing software and put 2 wallets on a 4x6 or 9 wallets on a full page.  The photo tray will not take paper smaller than 4x6.
    SandyBob
    If I have solved your issue, please feel free to provide kudos and make sure you mark this thread as solution provided!
    Although I work for HP, my posts and replies are my own opinion and not those of HP
    1-800-474-6836

  • Freezing when trying to print out PDF?

    Trying to print out PDF of Aperture 'book'. Each time it freezes on the same page ... this particular page is where I have one image stretched across two pages. Is this possibly a glitch with Aperture?
    Ben
    I've trashed my preferences several times; doesn't seem to help. I've also tried to use two copies of the same picture (right half on right page, left half on left page); but that doesn't work too well, as Aperture seems to want to favor one side or the other – and thus I can't adjust the two sides to match up properly.
    Any suggestions would be most appreciated, thank you,
    Ben

    Hi Allen,
    I'm all topped up, big graphics card, latest ver. of Tiger, permissions repaired every day or so. The mystery continues.
    I love the IDEA of the two page spread. Have longed for it in Pages, where I'm producing a whole series of books ... a lot of two page spreads (but done by using two versions of the same still).
    Thanks,
    Ben

  • New Ink Cartridge but can not print out/copy any document.

    I have HP Printer Deskjet 1050. I've just bought 1 x Original HP Ink Cartridge Colour Black No.61 that can be used as well for my HP Deskjet 1050 (because I could't get No.802 Black Cartridge). I have pulled out the empty one and pushed the new one in until I heard snap sound (I've followed as what is in the instruction poster). Before my old Ink was empty, I was able to print either black or colour. Now, after I've got new one pushed in, I couldn't print nothing, even the alignment page doesn't automatically print out after all cartridges are pushed in and cartridge door was closed. My Black Ink warning light is blinking all the time. I can scan to my computer/laptop but can not print it out or make copy from the printer. This printer is not compatible for my laptop with OS Windows 8.1 (64-bit), but I was able to use my printer for printing thru my laptop by using HP AiO Printer Remote. Please help?

    Hi @KroebY, 
    Welcome to the HP support Forums! I see you have replaced the black cartridge on your HP Deskjet 1010, but it is not registering the new cartridge. You are unable to copy or print, you can make a scan. I notice you said your DJ 1010 was not compatible with the Windows 8.1 Operating system, there are full feature software and drivers available for your printer.
    Let's start troubleshooting the print quality issues: Printer Prints a Blank Page or Does Not Print Black or Color Ink for the HP Deskjet Ink Advantage an...
    Does this help, are you now able to print and make a copy? If yes, continue below:
    Now, the software:
    1. Unplug the USB if using a direct connection.
    2. Remove the HP DJ 1010 software from your computers Control Panel's Uninstall a program option.
    3. Restart the computer.
    4. Make sure all the DJ 1010 software is gone from the programs list as well as your HP folder listed under the All programs in your Start Menu.
    5. Now go ahead and download the software and drivers for your DJ 1010 (DO NOT plug in USB until the software prompts you to):
    http://h10025.www1.hp.com/ewfrf/wc/softwareDownloadIndex?softwareitem=dj-117518-4&cc=us&dlc=en&lc=en...
    6. Go ahead and print a test page.
    7. If you are unable to print a test page, please run the HP Print and Scan Doctor- It was designed by HP to provide users with the troubleshooting and problem solving features needed to resolve many common problems experienced with HP print and scan products connected to Windows-based computers.
    Please let me know if you are not able to print, and if the installation was successful.  I will watch for your reply.
    Thank you,
    HevnLgh
    I work on behalf of HP
    Please click “Accept as Solution” if you feel my post solved your issue, it will help others find the solution.
    Click the “Kudos Thumbs Up" to the left of the reply button to say “Thanks” for helping!

  • Print out in MB90 for GRN is not coming in English

    Dear Friends,
    While taking the print out in MB90 for GRN document, it is not coming in English.It is coming in some unreadableformat.
    In MN21 I have mentioned the language as EN.
    In the configuration of output type WE03 I have mentioned the language as EN intransaction code M706.
    A reply will be highly appreaciated.
    Regards
    Rutabhadra Panda

    hi
    check whether the printer you installed is having the proper driver.

  • Material price is not coming in PO print out

    Hi
    I am facing a problem for a cost cenetr PO material price is not coming in print preview as welll as in print out for a particular PO  what can be the problem.
    regards,
    zafar

    Solution in this link Print priview of Purchase Order

  • How t print out selected values from a Jlist

    hi iam trying to get the selected values from a list to print out as a string but iam getting ,Invalid cast from java.lang.Object[] to java.lang.String.is there any way to get the selected values t print ut as a string?? import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class MultipleSelection2 extends JFrame {
    private JList colorList, copyList;
    private JButton copy;
    private String colorNames[] =
    { "Black", "Blue", "Cyan", "Dark Gray", "Gray",
    "Green", "Light Gray", "Magenta", "Orange", "Pink",
    "Red", "White", "Yellow" };
    public MultipleSelection2()
    super( "Multiple Selection Lists" );
    Container c = getContentPane();
    c.setLayout( new FlowLayout() );
    colorList = new JList( colorNames );
    colorList.setVisibleRowCount( 5 );
    colorList.setFixedCellHeight( 15 );
    colorList.setSelectionMode(
    ListSelectionModel.MULTIPLE_INTERVAL_SELECTION );
    c.add( new JScrollPane( colorList ) );
    // create copy button
    copy = new JButton( "Copy >>>" );
    copy.addActionListener(
    new ActionListener() {
    public void actionPerformed( ActionEvent e )
    // place selected values in copyList
    copyList.setListData(
    colorList.getSelectedValues());
    String s1 =(String)colorList.getSelectedValues();

    Since the JList method 'getSelectedValues' returns an object array you'll need to iterate through the array and cast each object in the array to a string as you access them.
    Object[] o = colorList.getSelectedValues();
    for(int count=0,end=o.length; count<end; count++) {
    String s = (String) o[count];
    Hope that helps
    Talden

Maybe you are looking for