Wednesday, October 30, 2013

1.12 - Formats

/*
 * Autor: Juan Antonio Ripoll
 * Date: 30/10/13
 * 
 * Write a JAVA program to ask the user for a number and display 
 * four times in a row, separated with blank spaces, 
 * and then four times in the next row, with no separation.  
 * */

import java.util.Scanner;

public class Main {

 public static void main(String[] args) {
  Scanner in = new Scanner(System.in);
  
  System.out.print("Enter a digit: ");
  int digit = in.nextInt();
  
  System.out.println(digit + " " + digit + " " + digit + " " + digit);
  System.out.println(digit + "" + digit + "" + digit + "" + digit);
 }
}

No comments:

Post a Comment