Hello, just wondering how I can this look nice and neat, i've tweaked around with adding tabs and the around of spaces allowed via %5d. I just can't seem to make everything line up straight, and if i do the names arn't flush with the left boundary.
here is the java code
when executed i want it to display it in a nice pretty format. Thanks for your timeCode://*****************************************************************************
//Contacts.java
//Author William Cebak
//Date 25 September 2012
//
//
// This progam will take a text file that has a list of phone contacts. It will
// take all the information on the text file and re format them and orgainze them
// in a simple to read format.
//
//*****************************************************************************
import java.util.Scanner;
import java.io.*;
public class Contacts
{
//*************************************************************************
//Reads data from a file and prints their path components
//*************************************************************************
public static void main (String[] args) throws IOException
{
String Contactinfo;
Scanner fileScan, textScan;
int callouttotal = 0,callintotal = 0, contactcount = 0;
fileScan = new Scanner (new File("C:/Users/Tony/Desktop/phoneContacts.txt"));
System.out.println("\tName\t\tPhone\t\tCalls Out\tCalls In\tFavorite");
//Read and process each line of the file
while(fileScan.hasNext())
{
Contactinfo = fileScan.nextLine(); //reads all the
//this would display the actuall text line
textScan = new Scanner(Contactinfo);
textScan.useDelimiter("#"); // takes out the # symbol
while (textScan.hasNext()) //reads until there is no more to read
{
//Creats a variable for the last name and keep count for total contacts
String Lastname= textScan.next();
contactcount ++;
//Creates a variable for the first name
String Firstname= textScan.next();
//Creates a variable for Phone Number
String Phonenumber = textScan.next();
//Creates a variable for Calls out and keeps a count
String Callout = textScan.next();
Integer calloutnum = Integer.valueOf(Callout);
callouttotal = (callouttotal + calloutnum);
//Creates a variable for calls in and keeps a count
String Callin = textScan.next();
Integer callinnum = Integer.valueOf(Callin);
callintotal = (callintotal+ callinnum);
//Creates a variable for favorite and keeps a count
String Favorite = textScan.next();
//if (Favorite == "Y")
//{
// int favoritecount = 0;
// favoritecount++;
//}
//*************************************************************
// outputs the contact list in a pretty fashion :)
//*************************************************************
String Fullname = Firstname + " " + Lastname;
System.out.printf("%s\t%12s%d\t\t%d\t\t%s",Fullname,
Phonenumber, callinnum, calloutnum, Favorite);
System.out.println();
}
}
System.out.print("\n\n");
System.out.println("Total outgoing calls for the period:\t\t" + callouttotal);
System.out.println("Total incoming calls for the period:\t\t" + callintotal);
System.out.println("Total contacts:\t\t\t\t\t" + contactcount);
}
}
