Hallo,
ich bin neu in Android Studio, und mich interessiert am meisten wie ich dieses folgende Testprogramm für Mathematik auf meinem Androidsystem laufen lassen kann. Es funktioniert ja ohne weitere Probleme in der Console auf dem PC.
ich bin neu in Android Studio, und mich interessiert am meisten wie ich dieses folgende Testprogramm für Mathematik auf meinem Androidsystem laufen lassen kann. Es funktioniert ja ohne weitere Probleme in der Console auf dem PC.
Java:
package coords;
import java.util.Scanner;
class ConsoleMenu
{
void ShowMenu()
{
System.out.println( "\n" + 1 + " TriA.Coord\n" + 2 + " TriA.Func\n" );
}
ConsoleMenu()
{}
}
public class coord_2d
{
public static void main( String[] args ) throws java.io.IOException
{
ConsoleMenu cs = new ConsoleMenu();
char ch;
do
{
cs.ShowMenu();
ch = (char) System.in.read();
switch( ch )
{
case '1':
{
System.out.println( "Tri Coord" );
double Sx, Sy, h2, m1, m2, x01, x02, n1, n2, af, u, a1, a, b1, b, c, atan, btan, ctan, m3,
n3, qx1, qx01, qx2, qx02;
System.out.println( "Geben Sie alle Koordinaten ein:" );
Scanner sc = new Scanner( System.in );
System.out.println( "A-x:" );
double ax = sc.nextDouble();
System.out.println( "A-y:" );
double ay = sc.nextDouble();
System.out.println( "B-x:" );
double bx = sc.nextDouble();
System.out.println( "B-y:" );
double by = sc.nextDouble();
System.out.println( "C-x:" );
double cx = sc.nextDouble();
System.out.println( "C-y:" );
double cy = sc.nextDouble();
System.out.println( "D-x:" );
double dx = sc.nextDouble();
System.out.println( "D-y:" );
double dy = sc.nextDouble();
sc.close();
System.out.println( "A: (" + ax + " ; " + ay + ") B: (" + bx + " ; " + by + ")" );
System.out.println( "D: (" + cx + " ; " + cy + ") C: (" + dx + " ; " + dy + ")\n" );
//m1/m2
m1 = ( by - ay ) / ( bx - ax );
m2 = ( dy - cy ) / ( dx - cx );
System.out.println( "m1= " + m1 + "\n" + "m2= " + m2 );
//n1/n2
n1 = ( m1 * ax * -1 ) + ay;
n2 = ( m2 * cx * -1 ) + cy;
System.out.println( "n1= " + n1 + "\n" + "n2= " + n2 );
//x0
x01 = ( n1 * -1 ) / m1;
x02 = ( n2 * -1 ) / m2;
System.out.println( "x01= " + x01 + "\n" + "x02= " + x02 );
//g
double x01g = 0, x02g = 0;
if ( x01 <= 0 )
{
x01g = x01 * -1;
}
else x01g = x01;
if ( x02 <= 0 )
{
x02g = x02 * -1;
}
else x02g = x02;
c = x01g + x02g;
//S
System.out.println( "\n" + m1 + "x + " + n1 + " = " + m2 + "x + " + n2 );
m3 = ( m2 * -1 ) + m1;
n3 = ( n1 * -1 ) + n2;
Sx = n3 / m3;
Sy = m1 * Sx + n1;
System.out.println( "S(x;y/h)= (" + Sx + " ; " + Sy + ")" );
//seiten
h2 = Sy * Sy;
qx1 = x01 - Sx;
qx01 = qx1 * qx1;
b1 = qx01 + h2;
b = Math.sqrt( b1 );
qx2 = x02 - Sx;
qx02 = qx2 * qx2;
a1 = qx02 + h2;
a = Math.sqrt( a1 );
System.out.println( "\na= " + a + " LE\nb= " + b + " LE\nc= " + c + " LE" );
//U + A
u = a + b + c;
af = 0.5 * c * Sy;
System.out.println( "\nu= " + u + " LE\nA= " + af + " FE" );
//winkel
atan = Math.toDegrees( Math.atan( m1 ) );
btan = Math.toDegrees( Math.atan( m2 ) );
if ( atan < 0 )
atan = atan * -1;
if ( btan < 0 )
btan = btan * -1;
ctan = 180 - ( atan + btan );
System.out.println( "\nalpha: " + atan + "\nbeta : " + btan + "\ngamma: " + ctan );
}
break;
case '2':
{
System.out.println( "Tri Func" );
double Sx, Sy, h2, x01, x02, af, u, a1, a, b1, b, c, atan, btan, ctan, m3,
n3, qx1, qx01, qx2, qx02;
System.out.println( "Geben Sie alle Koordinaten ein:" );
Scanner sc = new Scanner( System.in );
System.out.println( "y1 m:" );
double y1m = sc.nextDouble();
System.out.println( "y1 n:" );
double y1n = sc.nextDouble();
System.out.println( "y2 m:" );
double y2m = sc.nextDouble();
System.out.println( "y2 n:" );
double y2n = sc.nextDouble();
sc.close();
System.out.println( "y1(x) = " + y1m + "x + " + y1n + "\ny2(x) = " + y2m + "x + " + y2n );
//x0
x01 = ( y1n * -1 ) / y1m;
x02 = ( y2n * -1 ) / y2m;
System.out.println( "x01= " + x01 + "\n" + "x02= " + x02 );
//g
double x01g = 0, x02g = 0;
if ( x01 < 0 )
{
x01g = x01 * -1;
}
else x01g = x01;
if ( x02 < 0 )
{
x02g = x02 * -1;
}
else x02g = x02;
c = x01g + x02g;
//S
m3 = ( y2m * -1 ) + y1m;
n3 = ( y1n * -1 ) + y2n;
Sx = n3 / m3;
Sy = y1m * Sx + y1n;
System.out.println( "S(x;y/h)= (" + Sx + " ; " + Sy + ")" );
//seiten
h2 = Sy * Sy;
qx1 = x01 - Sx;
qx01 = qx1 * qx1;
b1 = qx01 + h2;
b = Math.sqrt( b1 );
qx2 = x02 - Sx;
qx02 = qx2 * qx2;
a1 = qx02 + h2;
a = Math.sqrt( a1 );
System.out.println( "\na= " + a + " LE\nb= " + b + " LE\nc= " + c + " LE" );
//U + A
u = a + b + c;
af = 0.5 * c * Sy;
System.out.println( "\nu= " + u + " LE\nA= " + af + " FE" );
//winkel
atan = Math.toDegrees( Math.atan( y1m ) );
btan = Math.toDegrees( Math.atan( y2m ) );
if ( atan < 0 )
atan = atan * -1;
if ( btan < 0 )
btan = btan * -1;
ctan = 180 - ( atan + btan );
System.out.println( "\nalpha: " + atan + "\nbeta : " + btan + "\ngamma: " + ctan );
}
break;
}
}
while ( ch != '0' );
}
}