Results 1 to 2 of 2
  1. #1
    sjicho is offline Member
    Join Date
    Oct 2012
    Posts
    4
    Rep Power
    0

    Default How to post code

    try

    import java.util.Scanner;

    public class Help {
    public static void main(String args[]) {
    Scanner scanner = new Scanner(System.in);
    System.out.print("Please enter a number: ");
    int intNumber = scanner.nextInt();

    String strNumber = String.valueOf(intNumber);

    int intNumberOfSevens = 0;
    char chrComparison = '7';

    for(int i = 0;i < strNumber.length();i++) {
    char chrTemp = strNumber.charAt(i);
    if(chrComparison == chrTemp) {
    intNumberOfSevens++;
    }
    }

    System.out.println("Number of seven's is : " + intNumberOfSevens);
    }
    }

    and my question is how do you print code like that on the forum

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,457
    Rep Power
    20

    Default Re: How to post code

    Removed from Counting # of 7's in an integer

    When you have a question, start your own thread. Don't hijack another poster's thread with an unrelated question.

    There are several links near the top of every forum page, did you try clicking around to see what you could discover about using the forum?

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Code question. Where to post.
    By Tullamore in forum New To Java
    Replies: 6
    Last Post: 04-06-2012, 06:10 AM
  2. Replies: 3
    Last Post: 05-04-2009, 04:15 AM
  3. Please post your suggestions about this code
    By mathansj in forum Advanced Java
    Replies: 8
    Last Post: 02-15-2009, 04:41 PM

Posting Permissions

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