SlideShare a Scribd company logo
Write a java program that reads a number N as input and displays the following output using
stacks with parameters. Example o Input: Enter N: o Output: 5
Solution
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Stacks {
public static void main(String[] args) throws IOException {
// used variables
BufferedReader reader;
String input,outerSpaces,innerSpaces;
Integer number;
// taking input
System.out.print("Enter N : ");
reader = new BufferedReader(new InputStreamReader(System.in));
input = reader.readLine();
number = Integer.parseInt(input);
// printing upper stack
for(int i=1;i0;i--){
outerSpaces = getOuterSpaces(i);
innerSpaces = getInnerSpaces(number, i);
System.out.print(outerSpaces);
System.out.print(i);
System.out.print(innerSpaces);
if(i != number){
System.out.print(i);
}
System.out.print(outerSpaces);
System.out.println();
}
}
public static String getOuterSpaces(int offset){
StringBuffer buffer = new StringBuffer("");
for(int i=0;i

More Related Content

Similar to Write a java program that reads a number N as input and displays the.pdf

Java ppt
Java pptJava ppt
Java ppt
Rohan Gajre
 
Lab4
Lab4Lab4
Reading and writting v2
Reading and writting v2Reading and writting v2
Reading and writting v2ASU Online
 
import java.io.BufferedReader;import java.io.File;import java.io.pdf
import java.io.BufferedReader;import java.io.File;import java.io.pdfimport java.io.BufferedReader;import java.io.File;import java.io.pdf
import java.io.BufferedReader;import java.io.File;import java.io.pdf
manojmozy
 
In JavaWrite a program that reads a text file that contains a gra.pdf
In JavaWrite a program that reads a text file that contains a gra.pdfIn JavaWrite a program that reads a text file that contains a gra.pdf
In JavaWrite a program that reads a text file that contains a gra.pdf
mumnesh
 
Please help me with a UML class diagram for the following code im.pdf
Please help me with a UML class diagram for the following code im.pdfPlease help me with a UML class diagram for the following code im.pdf
Please help me with a UML class diagram for the following code im.pdf
aioils
 
Object oriented programming la bmanual jntu
Object oriented programming la bmanual jntuObject oriented programming la bmanual jntu
Object oriented programming la bmanual jntuKhurshid Asghar
 
Java Programs
Java ProgramsJava Programs
Java Programs
AnjaliSoorej
 
mport java.io.; class Student { int rollno; String name; .pdf
mport java.io.; class Student { int rollno; String name; .pdfmport java.io.; class Student { int rollno; String name; .pdf
mport java.io.; class Student { int rollno; String name; .pdf
aryan9007
 
import java.io.BufferedReader; import java.io.IOException; impor.pdf
import java.io.BufferedReader; import java.io.IOException; impor.pdfimport java.io.BufferedReader; import java.io.IOException; impor.pdf
import java.io.BufferedReader; import java.io.IOException; impor.pdf
aravlitraders2012
 
07-Basic-Input-Output.ppt
07-Basic-Input-Output.ppt07-Basic-Input-Output.ppt
07-Basic-Input-Output.ppt
Ajenkris Kungkung
 
Computer programming 2 chapter 1-lesson 2
Computer programming 2  chapter 1-lesson 2Computer programming 2  chapter 1-lesson 2
Computer programming 2 chapter 1-lesson 2
MLG College of Learning, Inc
 
import java.util.;public class Program{public static void.pdf
import java.util.;public class Program{public static void.pdfimport java.util.;public class Program{public static void.pdf
import java.util.;public class Program{public static void.pdf
optokunal1
 
JAVA Q2- Write a program that reads strings from the user and writes t.docx
JAVA Q2- Write a program that reads strings from the user and writes t.docxJAVA Q2- Write a program that reads strings from the user and writes t.docx
JAVA Q2- Write a program that reads strings from the user and writes t.docx
michael1810
 
InsertionSorting.javaimport java.util.Arrays; import java.util.S.pdf
InsertionSorting.javaimport java.util.Arrays; import java.util.S.pdfInsertionSorting.javaimport java.util.Arrays; import java.util.S.pdf
InsertionSorting.javaimport java.util.Arrays; import java.util.S.pdf
info54093
 
Write a program that will count the number of characters- words- and l.docx
Write a program that will count the number of characters- words- and l.docxWrite a program that will count the number of characters- words- and l.docx
Write a program that will count the number of characters- words- and l.docx
lez31palka
 
Javaa. The mean of a list of numbers is its arithmetic average. T.pdf
Javaa. The mean of a list of numbers is its arithmetic average. T.pdfJavaa. The mean of a list of numbers is its arithmetic average. T.pdf
Javaa. The mean of a list of numbers is its arithmetic average. T.pdf
RAJATCHUGH12
 
Lab101.pptx
Lab101.pptxLab101.pptx
Lab101.pptx
KimVeeL
 
(JAVA NetBeans) Write a Java program able to perform selection sort-So.docx
(JAVA NetBeans) Write a Java program able to perform selection sort-So.docx(JAVA NetBeans) Write a Java program able to perform selection sort-So.docx
(JAVA NetBeans) Write a Java program able to perform selection sort-So.docx
dorisc7
 
IN JAVA Write a program to create a binary data file named RandomInt.pdf
IN JAVA Write a program to create a binary data file named RandomInt.pdfIN JAVA Write a program to create a binary data file named RandomInt.pdf
IN JAVA Write a program to create a binary data file named RandomInt.pdf
herminaherman
 

Similar to Write a java program that reads a number N as input and displays the.pdf (20)

Java ppt
Java pptJava ppt
Java ppt
 
Lab4
Lab4Lab4
Lab4
 
Reading and writting v2
Reading and writting v2Reading and writting v2
Reading and writting v2
 
import java.io.BufferedReader;import java.io.File;import java.io.pdf
import java.io.BufferedReader;import java.io.File;import java.io.pdfimport java.io.BufferedReader;import java.io.File;import java.io.pdf
import java.io.BufferedReader;import java.io.File;import java.io.pdf
 
In JavaWrite a program that reads a text file that contains a gra.pdf
In JavaWrite a program that reads a text file that contains a gra.pdfIn JavaWrite a program that reads a text file that contains a gra.pdf
In JavaWrite a program that reads a text file that contains a gra.pdf
 
Please help me with a UML class diagram for the following code im.pdf
Please help me with a UML class diagram for the following code im.pdfPlease help me with a UML class diagram for the following code im.pdf
Please help me with a UML class diagram for the following code im.pdf
 
Object oriented programming la bmanual jntu
Object oriented programming la bmanual jntuObject oriented programming la bmanual jntu
Object oriented programming la bmanual jntu
 
Java Programs
Java ProgramsJava Programs
Java Programs
 
mport java.io.; class Student { int rollno; String name; .pdf
mport java.io.; class Student { int rollno; String name; .pdfmport java.io.; class Student { int rollno; String name; .pdf
mport java.io.; class Student { int rollno; String name; .pdf
 
import java.io.BufferedReader; import java.io.IOException; impor.pdf
import java.io.BufferedReader; import java.io.IOException; impor.pdfimport java.io.BufferedReader; import java.io.IOException; impor.pdf
import java.io.BufferedReader; import java.io.IOException; impor.pdf
 
07-Basic-Input-Output.ppt
07-Basic-Input-Output.ppt07-Basic-Input-Output.ppt
07-Basic-Input-Output.ppt
 
Computer programming 2 chapter 1-lesson 2
Computer programming 2  chapter 1-lesson 2Computer programming 2  chapter 1-lesson 2
Computer programming 2 chapter 1-lesson 2
 
import java.util.;public class Program{public static void.pdf
import java.util.;public class Program{public static void.pdfimport java.util.;public class Program{public static void.pdf
import java.util.;public class Program{public static void.pdf
 
JAVA Q2- Write a program that reads strings from the user and writes t.docx
JAVA Q2- Write a program that reads strings from the user and writes t.docxJAVA Q2- Write a program that reads strings from the user and writes t.docx
JAVA Q2- Write a program that reads strings from the user and writes t.docx
 
InsertionSorting.javaimport java.util.Arrays; import java.util.S.pdf
InsertionSorting.javaimport java.util.Arrays; import java.util.S.pdfInsertionSorting.javaimport java.util.Arrays; import java.util.S.pdf
InsertionSorting.javaimport java.util.Arrays; import java.util.S.pdf
 
Write a program that will count the number of characters- words- and l.docx
Write a program that will count the number of characters- words- and l.docxWrite a program that will count the number of characters- words- and l.docx
Write a program that will count the number of characters- words- and l.docx
 
Javaa. The mean of a list of numbers is its arithmetic average. T.pdf
Javaa. The mean of a list of numbers is its arithmetic average. T.pdfJavaa. The mean of a list of numbers is its arithmetic average. T.pdf
Javaa. The mean of a list of numbers is its arithmetic average. T.pdf
 
Lab101.pptx
Lab101.pptxLab101.pptx
Lab101.pptx
 
(JAVA NetBeans) Write a Java program able to perform selection sort-So.docx
(JAVA NetBeans) Write a Java program able to perform selection sort-So.docx(JAVA NetBeans) Write a Java program able to perform selection sort-So.docx
(JAVA NetBeans) Write a Java program able to perform selection sort-So.docx
 
IN JAVA Write a program to create a binary data file named RandomInt.pdf
IN JAVA Write a program to create a binary data file named RandomInt.pdfIN JAVA Write a program to create a binary data file named RandomInt.pdf
IN JAVA Write a program to create a binary data file named RandomInt.pdf
 

More from brijeshagarwa329898l

I studied analysis in Japanese textbook. Though I know many theorems.pdf
I studied analysis in Japanese textbook. Though I know many theorems.pdfI studied analysis in Japanese textbook. Though I know many theorems.pdf
I studied analysis in Japanese textbook. Though I know many theorems.pdf
brijeshagarwa329898l
 
I am in need of two separate files that I can save independently.pdf
I am in need of two separate files that I can save independently.pdfI am in need of two separate files that I can save independently.pdf
I am in need of two separate files that I can save independently.pdf
brijeshagarwa329898l
 
Heat transfer QuestionGiven a too hot to taste spoonful of soup.pdf
Heat transfer QuestionGiven a too hot to taste spoonful of soup.pdfHeat transfer QuestionGiven a too hot to taste spoonful of soup.pdf
Heat transfer QuestionGiven a too hot to taste spoonful of soup.pdf
brijeshagarwa329898l
 
Explain what it is that is used with a 9S12 processor to match a giv.pdf
Explain what it is that is used with a 9S12 processor to match a giv.pdfExplain what it is that is used with a 9S12 processor to match a giv.pdf
Explain what it is that is used with a 9S12 processor to match a giv.pdf
brijeshagarwa329898l
 
Duroc Jersey pigs are typically red, but a sandy variation is also s.pdf
Duroc Jersey pigs are typically red, but a sandy variation is also s.pdfDuroc Jersey pigs are typically red, but a sandy variation is also s.pdf
Duroc Jersey pigs are typically red, but a sandy variation is also s.pdf
brijeshagarwa329898l
 
Discuss the economic impact of technological sophistication.Solu.pdf
Discuss the economic impact of technological sophistication.Solu.pdfDiscuss the economic impact of technological sophistication.Solu.pdf
Discuss the economic impact of technological sophistication.Solu.pdf
brijeshagarwa329898l
 
Describe in detail the specimen of a potato with a drop of iodine in.pdf
Describe in detail the specimen of a potato with a drop of iodine in.pdfDescribe in detail the specimen of a potato with a drop of iodine in.pdf
Describe in detail the specimen of a potato with a drop of iodine in.pdf
brijeshagarwa329898l
 
define two modes of speciation and provide examples of eachSolut.pdf
define two modes of speciation and provide examples of eachSolut.pdfdefine two modes of speciation and provide examples of eachSolut.pdf
define two modes of speciation and provide examples of eachSolut.pdf
brijeshagarwa329898l
 
computer math Use the following to answer questions 1-2 In the q.pdf
computer math Use the following to answer questions 1-2 In the q.pdfcomputer math Use the following to answer questions 1-2 In the q.pdf
computer math Use the following to answer questions 1-2 In the q.pdf
brijeshagarwa329898l
 
CASe Stic ato wad duun SolutionAggregates used in this method a.pdf
CASe Stic ato wad duun SolutionAggregates used in this method a.pdfCASe Stic ato wad duun SolutionAggregates used in this method a.pdf
CASe Stic ato wad duun SolutionAggregates used in this method a.pdf
brijeshagarwa329898l
 
Write MatLAb code that would produce the following printSolution.pdf
Write MatLAb code that would produce the following printSolution.pdfWrite MatLAb code that would produce the following printSolution.pdf
Write MatLAb code that would produce the following printSolution.pdf
brijeshagarwa329898l
 
Why do rays run radially in a woody stemHow would wood produced i.pdf
Why do rays run radially in a woody stemHow would wood produced i.pdfWhy do rays run radially in a woody stemHow would wood produced i.pdf
Why do rays run radially in a woody stemHow would wood produced i.pdf
brijeshagarwa329898l
 
Why is the DNA fragment amplified with Phusion DNA into pGEM-T plasmi.pdf
Why is the DNA fragment amplified with Phusion DNA into pGEM-T plasmi.pdfWhy is the DNA fragment amplified with Phusion DNA into pGEM-T plasmi.pdf
Why is the DNA fragment amplified with Phusion DNA into pGEM-T plasmi.pdf
brijeshagarwa329898l
 
Which of these is a function of the skeletal system communication s.pdf
Which of these is a function of the skeletal system  communication s.pdfWhich of these is a function of the skeletal system  communication s.pdf
Which of these is a function of the skeletal system communication s.pdf
brijeshagarwa329898l
 
what is transport layer what are the typical attacks in transport l.pdf
what is transport layer what are the typical attacks in transport l.pdfwhat is transport layer what are the typical attacks in transport l.pdf
what is transport layer what are the typical attacks in transport l.pdf
brijeshagarwa329898l
 
Which monetary aggregate would you expect the Federal Reserve to hav.pdf
Which monetary aggregate would you expect the Federal Reserve to hav.pdfWhich monetary aggregate would you expect the Federal Reserve to hav.pdf
Which monetary aggregate would you expect the Federal Reserve to hav.pdf
brijeshagarwa329898l
 
wavelet decomposition process code in matlabSolution WAVE.pdf
wavelet decomposition process code in matlabSolution WAVE.pdfwavelet decomposition process code in matlabSolution WAVE.pdf
wavelet decomposition process code in matlabSolution WAVE.pdf
brijeshagarwa329898l
 
What happens if a red hot inoculation loop plunges into the nutrient .pdf
What happens if a red hot inoculation loop plunges into the nutrient .pdfWhat happens if a red hot inoculation loop plunges into the nutrient .pdf
What happens if a red hot inoculation loop plunges into the nutrient .pdf
brijeshagarwa329898l
 
What are speaking notes Have you used speaking notes before What wo.pdf
What are speaking notes Have you used speaking notes before What wo.pdfWhat are speaking notes Have you used speaking notes before What wo.pdf
What are speaking notes Have you used speaking notes before What wo.pdf
brijeshagarwa329898l
 
There are five components of internal control1) Control environme.pdf
There are five components of internal control1) Control environme.pdfThere are five components of internal control1) Control environme.pdf
There are five components of internal control1) Control environme.pdf
brijeshagarwa329898l
 

More from brijeshagarwa329898l (20)

I studied analysis in Japanese textbook. Though I know many theorems.pdf
I studied analysis in Japanese textbook. Though I know many theorems.pdfI studied analysis in Japanese textbook. Though I know many theorems.pdf
I studied analysis in Japanese textbook. Though I know many theorems.pdf
 
I am in need of two separate files that I can save independently.pdf
I am in need of two separate files that I can save independently.pdfI am in need of two separate files that I can save independently.pdf
I am in need of two separate files that I can save independently.pdf
 
Heat transfer QuestionGiven a too hot to taste spoonful of soup.pdf
Heat transfer QuestionGiven a too hot to taste spoonful of soup.pdfHeat transfer QuestionGiven a too hot to taste spoonful of soup.pdf
Heat transfer QuestionGiven a too hot to taste spoonful of soup.pdf
 
Explain what it is that is used with a 9S12 processor to match a giv.pdf
Explain what it is that is used with a 9S12 processor to match a giv.pdfExplain what it is that is used with a 9S12 processor to match a giv.pdf
Explain what it is that is used with a 9S12 processor to match a giv.pdf
 
Duroc Jersey pigs are typically red, but a sandy variation is also s.pdf
Duroc Jersey pigs are typically red, but a sandy variation is also s.pdfDuroc Jersey pigs are typically red, but a sandy variation is also s.pdf
Duroc Jersey pigs are typically red, but a sandy variation is also s.pdf
 
Discuss the economic impact of technological sophistication.Solu.pdf
Discuss the economic impact of technological sophistication.Solu.pdfDiscuss the economic impact of technological sophistication.Solu.pdf
Discuss the economic impact of technological sophistication.Solu.pdf
 
Describe in detail the specimen of a potato with a drop of iodine in.pdf
Describe in detail the specimen of a potato with a drop of iodine in.pdfDescribe in detail the specimen of a potato with a drop of iodine in.pdf
Describe in detail the specimen of a potato with a drop of iodine in.pdf
 
define two modes of speciation and provide examples of eachSolut.pdf
define two modes of speciation and provide examples of eachSolut.pdfdefine two modes of speciation and provide examples of eachSolut.pdf
define two modes of speciation and provide examples of eachSolut.pdf
 
computer math Use the following to answer questions 1-2 In the q.pdf
computer math Use the following to answer questions 1-2 In the q.pdfcomputer math Use the following to answer questions 1-2 In the q.pdf
computer math Use the following to answer questions 1-2 In the q.pdf
 
CASe Stic ato wad duun SolutionAggregates used in this method a.pdf
CASe Stic ato wad duun SolutionAggregates used in this method a.pdfCASe Stic ato wad duun SolutionAggregates used in this method a.pdf
CASe Stic ato wad duun SolutionAggregates used in this method a.pdf
 
Write MatLAb code that would produce the following printSolution.pdf
Write MatLAb code that would produce the following printSolution.pdfWrite MatLAb code that would produce the following printSolution.pdf
Write MatLAb code that would produce the following printSolution.pdf
 
Why do rays run radially in a woody stemHow would wood produced i.pdf
Why do rays run radially in a woody stemHow would wood produced i.pdfWhy do rays run radially in a woody stemHow would wood produced i.pdf
Why do rays run radially in a woody stemHow would wood produced i.pdf
 
Why is the DNA fragment amplified with Phusion DNA into pGEM-T plasmi.pdf
Why is the DNA fragment amplified with Phusion DNA into pGEM-T plasmi.pdfWhy is the DNA fragment amplified with Phusion DNA into pGEM-T plasmi.pdf
Why is the DNA fragment amplified with Phusion DNA into pGEM-T plasmi.pdf
 
Which of these is a function of the skeletal system communication s.pdf
Which of these is a function of the skeletal system  communication s.pdfWhich of these is a function of the skeletal system  communication s.pdf
Which of these is a function of the skeletal system communication s.pdf
 
what is transport layer what are the typical attacks in transport l.pdf
what is transport layer what are the typical attacks in transport l.pdfwhat is transport layer what are the typical attacks in transport l.pdf
what is transport layer what are the typical attacks in transport l.pdf
 
Which monetary aggregate would you expect the Federal Reserve to hav.pdf
Which monetary aggregate would you expect the Federal Reserve to hav.pdfWhich monetary aggregate would you expect the Federal Reserve to hav.pdf
Which monetary aggregate would you expect the Federal Reserve to hav.pdf
 
wavelet decomposition process code in matlabSolution WAVE.pdf
wavelet decomposition process code in matlabSolution WAVE.pdfwavelet decomposition process code in matlabSolution WAVE.pdf
wavelet decomposition process code in matlabSolution WAVE.pdf
 
What happens if a red hot inoculation loop plunges into the nutrient .pdf
What happens if a red hot inoculation loop plunges into the nutrient .pdfWhat happens if a red hot inoculation loop plunges into the nutrient .pdf
What happens if a red hot inoculation loop plunges into the nutrient .pdf
 
What are speaking notes Have you used speaking notes before What wo.pdf
What are speaking notes Have you used speaking notes before What wo.pdfWhat are speaking notes Have you used speaking notes before What wo.pdf
What are speaking notes Have you used speaking notes before What wo.pdf
 
There are five components of internal control1) Control environme.pdf
There are five components of internal control1) Control environme.pdfThere are five components of internal control1) Control environme.pdf
There are five components of internal control1) Control environme.pdf
 

Recently uploaded

2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
EduSkills OECD
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
Vivekanand Anglo Vedic Academy
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 

Recently uploaded (20)

2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
The French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free downloadThe French Revolution Class 9 Study Material pdf free download
The French Revolution Class 9 Study Material pdf free download
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 

Write a java program that reads a number N as input and displays the.pdf

  • 1. Write a java program that reads a number N as input and displays the following output using stacks with parameters. Example o Input: Enter N: o Output: 5 Solution import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Stacks { public static void main(String[] args) throws IOException { // used variables BufferedReader reader; String input,outerSpaces,innerSpaces; Integer number; // taking input System.out.print("Enter N : "); reader = new BufferedReader(new InputStreamReader(System.in)); input = reader.readLine(); number = Integer.parseInt(input); // printing upper stack for(int i=1;i0;i--){ outerSpaces = getOuterSpaces(i); innerSpaces = getInnerSpaces(number, i); System.out.print(outerSpaces); System.out.print(i); System.out.print(innerSpaces); if(i != number){ System.out.print(i); } System.out.print(outerSpaces); System.out.println(); } }
  • 2. public static String getOuterSpaces(int offset){ StringBuffer buffer = new StringBuffer(""); for(int i=0;i