Results 1 to 2 of 2
- 07-22-2007, 09:05 PM #1
Member
- Join Date
- Jul 2007
- Posts
- 40
- Rep Power
- 0
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.
i cant test this my console isn't working right, and i haven't finished my compiler install.Java 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 ");???? } }
Thanks
- 07-23-2007, 04:33 PM #2
Senior Member
- Join Date
- Jul 2007
- Posts
- 130
- Rep Power
- 0
Similar Threads
-
a simple code (cldc or midp) to write a text file ouside of the application package
By sina in forum CLDC and MIDPReplies: 3Last Post: 12-12-2008, 12:12 PM -
Addition program that displays the sum of two numbers
By Java Tip in forum Java TipReplies: 0Last Post: 03-28-2008, 08:46 PM -
Reading in data from file line by line
By bluekswing in forum New To JavaReplies: 1Last Post: 10-02-2007, 12:19 AM -
Displaying numbers per line on a JOptionPane.showMessageDialog screen
By zoe in forum New To JavaReplies: 1Last Post: 07-31-2007, 04:01 AM -
Problem when displays in the terminal
By Felissa in forum Advanced JavaReplies: 2Last Post: 07-01-2007, 02:14 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks