dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Please Help

  1. #1
    Join Date
    Nov 2016
    Posts
    1

    Please Help

    I'm trying to get this code to compile into a program that prints a variable numerous times on a line. that runs continuous until it reaches the user input. I have been given this and I can't understand where to place the loops or what code to add. I have worked out the return value, and not I am lost from there. any help would be appreciated.

    Code:
    import java.util.*;
    public class PrintLines
    {
        public static void main(String[] args)
        {
            Scanner keyboard = new Scanner(System.in);
            int lines;
            int perLine;
            char theChar;
            int charsPrinted;
    
            do
            {
                System.out.print("How many lines do you want? ");
                lines = keyboard.nextInt();
                System.out.print("How many characters per line? ");
                perLine = keyboard.nextInt();
                System.out.print("What character? ");
                theChar = charString.charAt(0);
    
                charsPrinted = printLines(lines,perLine,theChar);
                System.out.println("main reports " + charsPrinted
                + "characters printed.");
                System.out.print("\nDo another? (y/n) ");
                System.out.flush();
    
            } while (keyboard.next().equalsIgnoreCase("y"));
            System.out.println("Goodbye!");
        }
    
        public static int printLines(int a,int b,char c)
            {
                int result;
                result = a * b;
    
                return result;
             }
    }
    Last edited by 2kaud; November 17th, 2016 at 11:01 AM. Reason: Code tags added

  2. #2
    Join Date
    Jun 1999
    Location
    Eastern Florida
    Posts
    3,856

    Re: Please Help

    Can you copy and paste here the program's current output.
    Add some comments to show what you want the output to be.

    Please edit your post and wrap your code with code tags:

    [code]
    **YOUR CODE GOES HERE**
    [/code]

    to get highlighting and preserve formatting.
    Norm

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)