Write a program that uses the DrawingPanel to produces the following f.docx

D

Write a program that uses the DrawingPanel to produces the following figure. Solution import java.awt.*; public class DrawingEx { public static void main(String [] args) { DrawingPanel panel= new DrawingPanel(500,400); Graphics g = panel.getGraphics(); g.setFont(new Font (\"Monospaced\",Font.Bold,14)); Scanner s=new Scanner(System.in); System.out.println(\"enter number of lines\"); int n= Integer.parseInt(s.readLine()); int m=n; for(int i=0;i<n;i++) { for(int j=0;j<m-1;j++) { System.out.println(\" \"); g.drawLine(m-1,0,m,n) m--; n--; } } } .

Write a program that uses the DrawingPanel to produces the following figure.
Solution
import java.awt.*;
public class DrawingEx
{
public static void main(String [] args)
{
DrawingPanel panel= new DrawingPanel(500,400);
Graphics g = panel.getGraphics();
g.setFont(new Font ("Monospaced",Font.Bold,14));
Scanner s=new Scanner(System.in);
System.out.println("enter number of lines");
int n= Integer.parseInt(s.readLine());
int m=n;
for(int i=0;i<n;i++)
{
for(int j=0;j<m-1;j++)
{
System.out.println(" ");
g.drawLine(m-1,0,m,n)
m--;
n--;
}
}
}

More Related Content

More from drosa1(20)

Recently uploaded(20)

Lecture: Open InnovationLecture: Open Innovation
Lecture: Open Innovation
Michal Hron82 views
Education and Diversity.pptxEducation and Diversity.pptx
Education and Diversity.pptx
DrHafizKosar56 views
Structure and Functions of Cell.pdfStructure and Functions of Cell.pdf
Structure and Functions of Cell.pdf
Nithya Murugan142 views
SIMPLE PRESENT TENSE_new.pptxSIMPLE PRESENT TENSE_new.pptx
SIMPLE PRESENT TENSE_new.pptx
nisrinamadani2146 views
Psychology KS5Psychology KS5
Psychology KS5
WestHatch53 views
AI Tools for Business and StartupsAI Tools for Business and Startups
AI Tools for Business and Startups
Svetlin Nakov57 views
STYP infopack.pdfSTYP infopack.pdf
STYP infopack.pdf
Fundacja Rozwoju Społeczeństwa Przedsiębiorczego143 views
Dance KS5 BreakdownDance KS5 Breakdown
Dance KS5 Breakdown
WestHatch52 views
CWP_23995_2013_17_11_2023_FINAL_ORDER.pdfCWP_23995_2013_17_11_2023_FINAL_ORDER.pdf
CWP_23995_2013_17_11_2023_FINAL_ORDER.pdf
SukhwinderSingh895865467 views
Streaming Quiz 2023.pdfStreaming Quiz 2023.pdf
Streaming Quiz 2023.pdf
Quiz Club NITW87 views
ACTIVITY BOOK key water sports.pptxACTIVITY BOOK key water sports.pptx
ACTIVITY BOOK key water sports.pptx
Mar Caston Palacio132 views
Industry4wrd.pptxIndustry4wrd.pptx
Industry4wrd.pptx
BC Chew153 views
231112 (WR) v1  ChatGPT OEB 2023.pdf231112 (WR) v1  ChatGPT OEB 2023.pdf
231112 (WR) v1 ChatGPT OEB 2023.pdf
WilfredRubens.com100 views
BYSC infopack.pdfBYSC infopack.pdf
BYSC infopack.pdf
Fundacja Rozwoju Społeczeństwa Przedsiębiorczego144 views
Gopal Chakraborty Memorial Quiz 2.0 Prelims.pptxGopal Chakraborty Memorial Quiz 2.0 Prelims.pptx
Gopal Chakraborty Memorial Quiz 2.0 Prelims.pptx
Debapriya Chakraborty221 views

Write a program that uses the DrawingPanel to produces the following f.docx

  • 1. Write a program that uses the DrawingPanel to produces the following figure. Solution import java.awt.*; public class DrawingEx { public static void main(String [] args) { DrawingPanel panel= new DrawingPanel(500,400); Graphics g = panel.getGraphics(); g.setFont(new Font ("Monospaced",Font.Bold,14)); Scanner s=new Scanner(System.in); System.out.println("enter number of lines"); int n= Integer.parseInt(s.readLine()); int m=n; for(int i=0;i<n;i++) { for(int j=0;j<m-1;j++) {