-3
Is there a way that I can take a program that works perfectly well in
Eclipse/jGrasp and put it into Android Studio and make it run...
import java.util.Scanner;
import javax.swing.JOptionPane;
public class MathLab
{
public static double side, length, width, height, base1, base2,
radius;
public static void main (String args[])
{
System.out.println("Geometry cheat sheet");
enterData();
display2DPerimeters();
display2DAreas();
display3DSurfaceAreas();
display3DVolumes();
//Geometry.
}
public static void enterData()
{
Scanner input = new Scanner(System.in);
System.out.print("Enter Side ===>> ");
side = input.nextDouble();
System.out.print("Enter Length ===>> ");
length = input.nextDouble();
System.out.print("Enter Width ===>> ");
width = input.nextDouble();
System.out.print("Enter Height ===>> ");
height = input.nextDouble();
System.out.print("Enter Base1 ===>> ");
base1 = input.nextDouble();
System.out.print("Enter Base2 ===>> ");
base2 = input.nextDouble();
System.out.print("Enter Radius ===>> ");
radius = input.nextDouble();
}
// Remove comments from the println statements below as you complete
それぞれ ジオメトリクラスのメソッド。 // が終了していないメソッドのコメントをそのまま残しておきます。Androidアプリの作成
public static void display2DPerimeters()
{
System.out.println("\n\nPerimeters of 2D Shapes");
System.out.println("______________________________________________");
System.out.println("Square Perimeter: " +
Geometry.squarePerimeter(side));
System.out.println("Pentagon Perimeter: " +
Geometry.pentagonPerimeter(side));
System.out.println("Hexagon Perimeter: " +
Geometry.hexagonPerimeter(side));
System.out.println("Octagon Perimeter: " +
Geometry.octagonPerimeter(side));
System.out.println("Rectangle Perimeter: " +
Geometry.rectanglePerimeter(length,width));
System.out.println("Circle Perimeter (circumference): " +
Geometry.circumference(radius));
}//*/
public static void display2DAreas()
{
System.out.println("Areas of 2D Shapes");
System.out.println("___________");
System.out.println("Square Area: " +
Geometry.squareArea(side));
System.out.println("Rectangle Area: " +
Geometry.rectangleArea(length,width));
System.out.println("Parallelogram Area: " +
Geometry.parallelogramArea(base1,height));
System.out.println("Triangle Area: " +
Geometry.triangleArea(base1,height));
System.out.println("Trapezoid Area: " +
enter code hereGeometry.trapezoidArea(base1,base2,height));
System.out.println("Hexagon Area: " +
Geometry.hexagonArea(height));
System.out.println("Circle Area: " +
Geometry.circleArea(radius));
}
public static void display3DSurfaceAreas()
{
System.out.println("Surface Areas of 3D Shapes");
System.out.println("=======================================");
System.out.println("Cube Surface Area: " +
Geometry.cubeSurfaceArea(side));
System.out.println("Square Prism Surface Area: " +
Geometry.squarePrismSurfaceArea(side,height));
//System.out.println("Rectangular Prism Surface Area: " +
Geometry.rectangularPrismSurfaceArea(length,width,height));
System.out.println("Sphere Surface Area: " +
Geometry.sphereSurfaceArea(radius));
}
public static void display3DVolumes()
{
System.out.println("Volumes of 3D Shapes");
System.out.println("=====================================================");
System.out.println("Cube Volume: " +
Geometry.cubeVolume(side));
System.out.println("Square Prism Volume: " +
Geometry.squarePrismVolume(side,height));
System.out.println("Rectangular Prism Volume: " +
Geometry.rectangularPrismVolume(length,width,height));
System.out.println("Pyramid Volume: " +
Geometry.pyramidVolume(side,height,length));
System.out.println("Cylinder Volume: " +
Geometry.cylinderVolume(radius,height));
//System.out.println("Cone Volume: " +
Geometry.coneVolume(radius,height));
//System.out.println("Sphere Volume: " +
Geometry.sphereVolume(radius));
}
}
class Geometry
{
// 2D Perimeters
public static double squarePerimeter(double side){return 4 * side;}
public static double pentagonPerimeter(double side){return 5 *
side;}
public static double hexagonPerimeter(double side){return 6 * side;}
public static double octagonPerimeter(double side){return 8 * side;}
public static double rectanglePerimeter(double l, double w){return 2
/(l * w);}
public static double circumference(double r){return 2*Math.PI*r;}
// 2D Areas
public static double squareArea (double s){ return s * s; }
public static double rectangleArea(double l, double w){return l * w;}
public static double parallelogramArea(double b, double h){return b *
h;}
public static double triangleArea(double h, double b){return (h *
b)/2;}
public static double trapezoidArea(double a, double b, double h){
{return (a += b/2)*h;}
public static double hexagonArea(double a){return ((3*
1.73205080757)/(2)) * a;}
public static double circleArea(double r){return Math.PI*r*r;}
// 3D Surface Areas
public static double cubeSurfaceArea (double s) { return 6 * s * s;
}
public static double squarePrismSurfaceArea(double a, double h)
{return 2 *(a * a) + 4 * a * h;}
public static double sphereSurfaceArea(double r) {return 4 * Math.PI
* (r * r);}
// 3D Volumes
public static double cubeVolume (double s){return s * s * s;}
public static double squarePrismVolume(double a, double h){return (a
* a) * h;}
public static double rectangularPrismVolume(double w, double h,
double l){return w * h * l;}
public static double pyramidVolume(double l, double w, double h)
{return (l * w * h)/3;}
public static double cylinderVolume(double r, double h){return
Math.PI * (r * r) * h;}
}
だからどうやらスタックオーバーフローが、私は自分のベストを尽くしますので、私はいくつかのコンテキストを追加したい、主な方法は、基本的に、我々は用事それが離れていったし、後に使用する他の方法を構築しています!
「それは去っていきました」あなたは半ば文にコンテキストを提供停止すべきという意味ではありません。私はあなたが何を求めているのか不明であるので閉じようとしています。あなたは自分自身を説明したり、あなたの投稿を見やすく整形したりすることができないので、評価-1です。 – Wyzard
申し訳ありませんが、私の悪い、私は今、 –