Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-22-2007, 10:05 PM
Member
 
Join Date: Jul 2007
Posts: 40
toby is on a distinguished road
Write an application that displays the numbers 1 to 4 on the same line
Hi, I'm going to be taking an object oriented paradigm using java during intersession in a few months. I'm trying to brush up on it a bit and have come across a simple little problem that have no idea how to solve.
The problem is. Write an application that displays the numbers 1 to 4 on the same line, with each pair of adjacent numbers separated by one space.
Write the program using the following techniques:
  • Use one system.out.printLn statement.
  • Use four system.out.print statement.
  • Use one system.out.printf statement.

This is what i have so far but I'm a little lost.

Code:
public class Display { public static void main(String [] args) { System.out.print("1 "); System.out.print("2 "); System.out.print("3 "); System.out.print("4 "); System.out.println(" ");<----is that what that is supposed to look like, and where it goes? System.out.printf(" %s %s %s %s ");???? } }
i cant test this my console isn't working right, and i haven't finished my compiler install.
Thanks
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-23-2007, 05:33 PM
Senior Member
 
Join Date: Jul 2007
Posts: 130
cruxblack will become famous soon enough
Maybe u better show us how u want the output to look like
I dunno bout the others, but i don't really get what u mean
If u wanna print a number next to another why not just write them all using the print method?
Sorry, don't get ur point
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Addition program that displays the sum of two numbers Java Tip Java Tips 0 03-28-2008 09:46 PM
a simple code (cldc or midp) to write a text file ouside of the application package sina CLDC and MIDP 2 03-13-2008 11:33 AM
Reading in data from file line by line bluekswing New To Java 1 10-02-2007 01:19 AM
Displaying numbers per line on a JOptionPane.showMessageDialog screen zoe New To Java 1 07-31-2007 05:01 AM
Problem when displays in the terminal Felissa Advanced Java 2 07-01-2007 03:14 AM


All times are GMT +3. The time now is 12:13 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org