SlideShare ist ein Scribd-Unternehmen logo
1 von 2
How to add right aligned spaces to make ascii table line up properly when using
System.out.printf()?
I am trying to print an ascii table that requires me to use System.out.printf(); and input from a 2-
dimensional array.
The array has 3 columns and 8 rows and contains these values.
10 1 2
100 0 1
1000 0 2
10000 1 3
100000 6 27
1000000 46 53
10000000 105 1192
100000000 954 11261
When trying to print the table with this method:
public static void print2dAsciiTable( long[][] data ) {
String spacer = "+---------------+-----------+-----------+n";
System.out.printf( spacer );
for (int row = 0; row < data.length; row++) {
System.out.printf( "| %,5d | %,7d | %,7d |n", data[row][0], data[row][1], data[row][2] );
System.out.printf( spacer );
}
}
I get this output:
How can I make it line up properly to have many spaces on the left of each number in the first
column with only 2 buffer spaces on the right side like it currently has?
I need the output to resemble this:
Thank you!
How to add right aligned spaces to make ascii table line up properly w.docx

Weitere ähnliche Inhalte

Ähnlich wie How to add right aligned spaces to make ascii table line up properly w.docx

Multi dimensional arrays
Multi dimensional arraysMulti dimensional arrays
Multi dimensional arraysAseelhalees
 
Chapter 7.4
Chapter 7.4Chapter 7.4
Chapter 7.4sotlsoc
 
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
1sequences and sampling. Suppose we went to sample the x-axis from X.pdfrushabhshah600
 
Basic R Data Manipulation
Basic R Data ManipulationBasic R Data Manipulation
Basic R Data ManipulationChu An
 
Introduction to matlab lecture 3 of 4
Introduction to matlab lecture 3 of 4Introduction to matlab lecture 3 of 4
Introduction to matlab lecture 3 of 4Randa Elanwar
 
C (PPS)Programming for problem solving.pptx
C (PPS)Programming for problem solving.pptxC (PPS)Programming for problem solving.pptx
C (PPS)Programming for problem solving.pptxrohinitalekar1
 
Arrays and library functions
Arrays and library functionsArrays and library functions
Arrays and library functionsSwarup Boro
 
JAVA PRACTICE QUESTIONS v1.4.pdf
JAVA PRACTICE QUESTIONS v1.4.pdfJAVA PRACTICE QUESTIONS v1.4.pdf
JAVA PRACTICE QUESTIONS v1.4.pdfRohitkumarYadav80
 
A quick introduction to R
A quick introduction to RA quick introduction to R
A quick introduction to RAngshuman Saha
 

Ähnlich wie How to add right aligned spaces to make ascii table line up properly w.docx (20)

Multi dimensional arrays
Multi dimensional arraysMulti dimensional arrays
Multi dimensional arrays
 
R Programming Intro
R Programming IntroR Programming Intro
R Programming Intro
 
Chapter 7.4
Chapter 7.4Chapter 7.4
Chapter 7.4
 
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
1sequences and sampling. Suppose we went to sample the x-axis from X.pdf
 
Basic R Data Manipulation
Basic R Data ManipulationBasic R Data Manipulation
Basic R Data Manipulation
 
Los dskn
Los dsknLos dskn
Los dskn
 
Introduction to matlab lecture 3 of 4
Introduction to matlab lecture 3 of 4Introduction to matlab lecture 3 of 4
Introduction to matlab lecture 3 of 4
 
WAP to add two given matrices in Java
WAP to add two given matrices in JavaWAP to add two given matrices in Java
WAP to add two given matrices in Java
 
Java file
Java fileJava file
Java file
 
Java file
Java fileJava file
Java file
 
2- Dimensional Arrays
2- Dimensional Arrays2- Dimensional Arrays
2- Dimensional Arrays
 
Python.pdf
Python.pdfPython.pdf
Python.pdf
 
C (PPS)Programming for problem solving.pptx
C (PPS)Programming for problem solving.pptxC (PPS)Programming for problem solving.pptx
C (PPS)Programming for problem solving.pptx
 
Matlab
MatlabMatlab
Matlab
 
MATLAB - Arrays and Matrices
MATLAB - Arrays and MatricesMATLAB - Arrays and Matrices
MATLAB - Arrays and Matrices
 
CLUSTERGRAM
CLUSTERGRAMCLUSTERGRAM
CLUSTERGRAM
 
Arrays and library functions
Arrays and library functionsArrays and library functions
Arrays and library functions
 
JAVA PRACTICE QUESTIONS v1.4.pdf
JAVA PRACTICE QUESTIONS v1.4.pdfJAVA PRACTICE QUESTIONS v1.4.pdf
JAVA PRACTICE QUESTIONS v1.4.pdf
 
Programming in R
Programming in RProgramming in R
Programming in R
 
A quick introduction to R
A quick introduction to RA quick introduction to R
A quick introduction to R
 

Mehr von Isaac9LjWelchq

help 4- A ray of light is sent in a random direction towards the x-axi.docx
help 4- A ray of light is sent in a random direction towards the x-axi.docxhelp 4- A ray of light is sent in a random direction towards the x-axi.docx
help 4- A ray of light is sent in a random direction towards the x-axi.docxIsaac9LjWelchq
 
hello- please dont just copy from other answers- the following is the.docx
hello- please dont just copy from other answers- the following is the.docxhello- please dont just copy from other answers- the following is the.docx
hello- please dont just copy from other answers- the following is the.docxIsaac9LjWelchq
 
Hello- I am working on writing a penetration test plan for a fictitiou.docx
Hello- I am working on writing a penetration test plan for a fictitiou.docxHello- I am working on writing a penetration test plan for a fictitiou.docx
Hello- I am working on writing a penetration test plan for a fictitiou.docxIsaac9LjWelchq
 
Hello- I am struggling with figuring out how to solve for this The hor.docx
Hello- I am struggling with figuring out how to solve for this The hor.docxHello- I am struggling with figuring out how to solve for this The hor.docx
Hello- I am struggling with figuring out how to solve for this The hor.docxIsaac9LjWelchq
 
Hello! I need help with below project-Thank You- Please name and expla.docx
Hello! I need help with below project-Thank You- Please name and expla.docxHello! I need help with below project-Thank You- Please name and expla.docx
Hello! I need help with below project-Thank You- Please name and expla.docxIsaac9LjWelchq
 
Hello I wanted to know if I can get help with my medical information c.docx
Hello I wanted to know if I can get help with my medical information c.docxHello I wanted to know if I can get help with my medical information c.docx
Hello I wanted to know if I can get help with my medical information c.docxIsaac9LjWelchq
 
Hector loved visiting and playing with his grandson- David- Today was.docx
Hector loved visiting and playing with his grandson- David- Today was.docxHector loved visiting and playing with his grandson- David- Today was.docx
Hector loved visiting and playing with his grandson- David- Today was.docxIsaac9LjWelchq
 
Health psychology is a(n) - based science because practitioners are tr.docx
Health psychology is a(n) - based science because practitioners are tr.docxHealth psychology is a(n) - based science because practitioners are tr.docx
Health psychology is a(n) - based science because practitioners are tr.docxIsaac9LjWelchq
 
Healthcare Operations Analysis Utilizing Information Technology Explai.docx
Healthcare Operations Analysis Utilizing Information Technology Explai.docxHealthcare Operations Analysis Utilizing Information Technology Explai.docx
Healthcare Operations Analysis Utilizing Information Technology Explai.docxIsaac9LjWelchq
 
Hearing 10- What is the function of each of the following anatomical f.docx
Hearing 10- What is the function of each of the following anatomical f.docxHearing 10- What is the function of each of the following anatomical f.docx
Hearing 10- What is the function of each of the following anatomical f.docxIsaac9LjWelchq
 
Health information is important to public health authorities during an.docx
Health information is important to public health authorities during an.docxHealth information is important to public health authorities during an.docx
Health information is important to public health authorities during an.docxIsaac9LjWelchq
 
he reflex and reaction lab helped us understand how different factors.docx
he reflex and reaction lab helped us understand how different factors.docxhe reflex and reaction lab helped us understand how different factors.docx
he reflex and reaction lab helped us understand how different factors.docxIsaac9LjWelchq
 
having trouble with my code I'm using VScode to code a javascript code.docx
having trouble with my code I'm using VScode to code a javascript code.docxhaving trouble with my code I'm using VScode to code a javascript code.docx
having trouble with my code I'm using VScode to code a javascript code.docxIsaac9LjWelchq
 
How they can live a more Eco-friendly- Sustainable and Community Engag.docx
How they can live a more Eco-friendly- Sustainable and Community Engag.docxHow they can live a more Eco-friendly- Sustainable and Community Engag.docx
How they can live a more Eco-friendly- Sustainable and Community Engag.docxIsaac9LjWelchq
 
How to determine whether a language is regular or not using Myhill-Ner.docx
How to determine whether a language is regular or not using Myhill-Ner.docxHow to determine whether a language is regular or not using Myhill-Ner.docx
How to determine whether a language is regular or not using Myhill-Ner.docxIsaac9LjWelchq
 
How many references are there to the list that refers to after the fol.docx
How many references are there to the list that refers to after the fol.docxHow many references are there to the list that refers to after the fol.docx
How many references are there to the list that refers to after the fol.docxIsaac9LjWelchq
 
How is the protective group removed to allow the addition of nucleotid.docx
How is the protective group removed to allow the addition of nucleotid.docxHow is the protective group removed to allow the addition of nucleotid.docx
How is the protective group removed to allow the addition of nucleotid.docxIsaac9LjWelchq
 
Has it been shown in the lab that simple organic compounds have formed.docx
Has it been shown in the lab that simple organic compounds have formed.docxHas it been shown in the lab that simple organic compounds have formed.docx
Has it been shown in the lab that simple organic compounds have formed.docxIsaac9LjWelchq
 
How many possible ways can you roll a seven- What is the probability o.docx
How many possible ways can you roll a seven- What is the probability o.docxHow many possible ways can you roll a seven- What is the probability o.docx
How many possible ways can you roll a seven- What is the probability o.docxIsaac9LjWelchq
 
have type O blood- (Round your answers to four decimal places-).docx
have type O blood- (Round your answers to four decimal places-).docxhave type O blood- (Round your answers to four decimal places-).docx
have type O blood- (Round your answers to four decimal places-).docxIsaac9LjWelchq
 

Mehr von Isaac9LjWelchq (20)

help 4- A ray of light is sent in a random direction towards the x-axi.docx
help 4- A ray of light is sent in a random direction towards the x-axi.docxhelp 4- A ray of light is sent in a random direction towards the x-axi.docx
help 4- A ray of light is sent in a random direction towards the x-axi.docx
 
hello- please dont just copy from other answers- the following is the.docx
hello- please dont just copy from other answers- the following is the.docxhello- please dont just copy from other answers- the following is the.docx
hello- please dont just copy from other answers- the following is the.docx
 
Hello- I am working on writing a penetration test plan for a fictitiou.docx
Hello- I am working on writing a penetration test plan for a fictitiou.docxHello- I am working on writing a penetration test plan for a fictitiou.docx
Hello- I am working on writing a penetration test plan for a fictitiou.docx
 
Hello- I am struggling with figuring out how to solve for this The hor.docx
Hello- I am struggling with figuring out how to solve for this The hor.docxHello- I am struggling with figuring out how to solve for this The hor.docx
Hello- I am struggling with figuring out how to solve for this The hor.docx
 
Hello! I need help with below project-Thank You- Please name and expla.docx
Hello! I need help with below project-Thank You- Please name and expla.docxHello! I need help with below project-Thank You- Please name and expla.docx
Hello! I need help with below project-Thank You- Please name and expla.docx
 
Hello I wanted to know if I can get help with my medical information c.docx
Hello I wanted to know if I can get help with my medical information c.docxHello I wanted to know if I can get help with my medical information c.docx
Hello I wanted to know if I can get help with my medical information c.docx
 
Hector loved visiting and playing with his grandson- David- Today was.docx
Hector loved visiting and playing with his grandson- David- Today was.docxHector loved visiting and playing with his grandson- David- Today was.docx
Hector loved visiting and playing with his grandson- David- Today was.docx
 
Health psychology is a(n) - based science because practitioners are tr.docx
Health psychology is a(n) - based science because practitioners are tr.docxHealth psychology is a(n) - based science because practitioners are tr.docx
Health psychology is a(n) - based science because practitioners are tr.docx
 
Healthcare Operations Analysis Utilizing Information Technology Explai.docx
Healthcare Operations Analysis Utilizing Information Technology Explai.docxHealthcare Operations Analysis Utilizing Information Technology Explai.docx
Healthcare Operations Analysis Utilizing Information Technology Explai.docx
 
Hearing 10- What is the function of each of the following anatomical f.docx
Hearing 10- What is the function of each of the following anatomical f.docxHearing 10- What is the function of each of the following anatomical f.docx
Hearing 10- What is the function of each of the following anatomical f.docx
 
Health information is important to public health authorities during an.docx
Health information is important to public health authorities during an.docxHealth information is important to public health authorities during an.docx
Health information is important to public health authorities during an.docx
 
he reflex and reaction lab helped us understand how different factors.docx
he reflex and reaction lab helped us understand how different factors.docxhe reflex and reaction lab helped us understand how different factors.docx
he reflex and reaction lab helped us understand how different factors.docx
 
having trouble with my code I'm using VScode to code a javascript code.docx
having trouble with my code I'm using VScode to code a javascript code.docxhaving trouble with my code I'm using VScode to code a javascript code.docx
having trouble with my code I'm using VScode to code a javascript code.docx
 
How they can live a more Eco-friendly- Sustainable and Community Engag.docx
How they can live a more Eco-friendly- Sustainable and Community Engag.docxHow they can live a more Eco-friendly- Sustainable and Community Engag.docx
How they can live a more Eco-friendly- Sustainable and Community Engag.docx
 
How to determine whether a language is regular or not using Myhill-Ner.docx
How to determine whether a language is regular or not using Myhill-Ner.docxHow to determine whether a language is regular or not using Myhill-Ner.docx
How to determine whether a language is regular or not using Myhill-Ner.docx
 
How many references are there to the list that refers to after the fol.docx
How many references are there to the list that refers to after the fol.docxHow many references are there to the list that refers to after the fol.docx
How many references are there to the list that refers to after the fol.docx
 
How is the protective group removed to allow the addition of nucleotid.docx
How is the protective group removed to allow the addition of nucleotid.docxHow is the protective group removed to allow the addition of nucleotid.docx
How is the protective group removed to allow the addition of nucleotid.docx
 
Has it been shown in the lab that simple organic compounds have formed.docx
Has it been shown in the lab that simple organic compounds have formed.docxHas it been shown in the lab that simple organic compounds have formed.docx
Has it been shown in the lab that simple organic compounds have formed.docx
 
How many possible ways can you roll a seven- What is the probability o.docx
How many possible ways can you roll a seven- What is the probability o.docxHow many possible ways can you roll a seven- What is the probability o.docx
How many possible ways can you roll a seven- What is the probability o.docx
 
have type O blood- (Round your answers to four decimal places-).docx
have type O blood- (Round your answers to four decimal places-).docxhave type O blood- (Round your answers to four decimal places-).docx
have type O blood- (Round your answers to four decimal places-).docx
 

Kürzlich hochgeladen

Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...PsychoTech Services
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 

Kürzlich hochgeladen (20)

Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
IGNOU MSCCFT and PGDCFT Exam Question Pattern: MCFT003 Counselling and Family...
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 

How to add right aligned spaces to make ascii table line up properly w.docx

  • 1. How to add right aligned spaces to make ascii table line up properly when using System.out.printf()? I am trying to print an ascii table that requires me to use System.out.printf(); and input from a 2- dimensional array. The array has 3 columns and 8 rows and contains these values. 10 1 2 100 0 1 1000 0 2 10000 1 3 100000 6 27 1000000 46 53 10000000 105 1192 100000000 954 11261 When trying to print the table with this method: public static void print2dAsciiTable( long[][] data ) { String spacer = "+---------------+-----------+-----------+n"; System.out.printf( spacer ); for (int row = 0; row < data.length; row++) { System.out.printf( "| %,5d | %,7d | %,7d |n", data[row][0], data[row][1], data[row][2] ); System.out.printf( spacer ); } } I get this output: How can I make it line up properly to have many spaces on the left of each number in the first column with only 2 buffer spaces on the right side like it currently has? I need the output to resemble this: Thank you!