0% found this document useful (0 votes)
3 views2 pages

jpr 30

The document contains Java applet code to demonstrate the drawing of basic 3D shapes including a cylinder, cube, and cone. It provides two separate programs: one for drawing multiple shapes and another focused on drawing a cone and cylinder. The applets utilize the Graphics class to render the shapes on the screen.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

jpr 30

The document contains Java applet code to demonstrate the drawing of basic 3D shapes including a cylinder, cube, and cone. It provides two separate programs: one for drawing multiple shapes and another focused on drawing a cone and cylinder. The applets utilize the Graphics class to render the shapes on the screen.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

PRACTICAL 30

Roll no: 230481

1. Demonstrate the use of basic applet, which includes different shapes like cone ,cube, cylinders.

Code:
import java.awt.*;
import java.applet.*;
/*<applet code=exp3031q1.class height=700 width=700></applet>*/
public class exp3031q1 extends Applet
{
public void paint(Graphics g)
{
/*Cylinder*/
g.drawString("(a).Cylinder",10,110);
g.drawOval(10,10,50,10);
g.drawOval(10,80,50,10);
g.drawLine(10,15,10,85);
g.drawLine(60,15,60,85);
/*Cube*/
g.drawString("(b).Cube",95,110);
g.drawRect(80,10,50,50);
g.drawRect(95,25,50,50);
g.drawLine(80,10,95,25);
g.drawLine(130,10,145,25);
g.drawLine(80,60,95,75);
g.drawLine(130,60,145,75);
/*Squar Inside A Circle*/
g.drawString("(c).Squar Inside A Circle",150,110);
g.drawOval(180,10,80,80);
g.drawRect(192,22,55,55);
/*Circle Inside a Square*/
g.drawString("(d).Circle Inside a Squar",290,110);
g.drawRect(290,10,80,80);
g.drawOval(290,10,80,80);
}
}
1. Develop a program to draw any 2 of the following shapes:
a. Cone
b. Cylinder
c. Cube
import java.io.*;
import java.awt.*;
import java.applet.*;

//<Applet code=exp3031q2.class WIDTH="800" HEIGHT="400"></Applet>


public class exp3031q2 extends Applet
{
public void paint(Graphics g)
{

/* To draw an cone*/
g.drawOval(200,80,200,50);
g.drawLine(200,100,300,500);
g.drawLine(400,100,300,500);

/* To draw a cyclinder*/
g.drawOval(500,60,200,50);
g.drawLine(500,80,500,300);
g.drawLine(700,80,700,300);
g.drawOval(500,280,200,50);

/* To draw a cube*/
g.drawRect(500,400,100,100);
g.drawRect(550,450,100,100);
g.drawLine(500,400,550,450);
g.drawLine(500,500,550,550);
g.drawLine(600,400,650,450);
g.drawLine(650,550,600,500);

}
}

You might also like