我是java的新手,我正在尝试创建一个程序,首先要求用户输入一些数字,然后输出一个卷,区域等等.另外我想显示一个矩形,我不知道怎么做,因为我的程序运行正常,它不会显示矩形.我能做什么?
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);
}
}
Run Code Online (Sandbox Code Playgroud)