I'm new in java and well I'm trying to create a program that will first ask the user to for some number and will output a volume, area and so on. Also I want to display a rectangle I don't know how that can be done because my program runs fine it just won't display the rectangle. What can I do?
package testchap3;
import java.util.*;
import javax.swing.JApplet;
import java.awt.*;
public class Chapter_3 extends JApplet
{
public void paint(Graphics page)
{
page.drawRect(50,50,60,60);
}
public static void main(String[] args)
{
int lenght,width,height,volume,Area,Perimeter;
Scanner scan = new Scanner(System.in);
System.out.println("What is the lenght:");
lenght = scan.nextInt();
System.out.println("What is the height:");
height = scan.nextInt();
System.out.println("What is the width:");
width= scan.nextInt();
volume = (lenght*height*width);
Area= volume/height;
Perimeter= lenght+width+lenght+width;
System.out.println("Your volume is:"+volume);
System.out.println("Your Area is:"+ Area);
System.out.println("Your perimeter is:"+Perimeter);
}
}
See Question&Answers more detail:os