Android Studio / Lauffähiges Javaprogramm importieren

waldfee

Mitglied
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.
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' );
  }
}
 

waldfee

Mitglied
ja gut, aber wie passe ich nun meinen code an? android studio kommt mit meinen scanne objecten und einigen anderem nicht klar..das sind so meine probleme..diese first steps halt..
 

Flown

Administrator
Mitarbeiter
Indem du mal Grundlagen von Android durchgehst und verstehst, dass es keine Konsole auf Android gibt. Da musst du dir schon eine UI bauen und dann das mit deinem Programm verknüpfen.
Wenn jetzt deine nächste Frage ist: "Wie mache ich das?", dann bist du noch nicht bereit für diesen Schritt und solltest noch etwas Grundlagen üben, bzw. dich in Android-Entwicklung einlesen.
 

waldfee

Mitglied
ja danke..sowas hatte ich mir gedacht..ich hoffte es gäbe einen einfacheren weg ;)
wie ich sowas mache ist mir bewusst.. aber danke ^^
 

Frithjof

Mitglied
Wenn es dir nur um einen Test geht, gibt es einen unsauberen weg - der bei zu langen ausgaben auch Fehler macht: Log.i("meintest", "Ausgabe" + i);
Das Löst nicht alle Probleme aber so kann man mal Testhalber auf der "Konsole" (Ja dem Syslog) was ausgeben.
Unsauber aber für nen klleinen Test eine Hilfe.
 
Ähnliche Java Themen
  Titel Forum Antworten Datum
M Repository bei Room-Database in Android Studio (Java) Android & Cross-Platform Mobile Apps 2
W In Android Studio Integer an andere activities übergeben Android & Cross-Platform Mobile Apps 2
wladp Android Studio Room Database Android & Cross-Platform Mobile Apps 1
T Android Studio: Einen Button in einer For Schleife verwenden Android & Cross-Platform Mobile Apps 2
K BLE Komunikation mit Android studio und esp32 Android & Cross-Platform Mobile Apps 5
M Paper DB wird in Android Studio nicht erkannt Android & Cross-Platform Mobile Apps 7
lolcore Android Studio -Download Documentation for Android SDK Android & Cross-Platform Mobile Apps 0
W Problem mit Android Studio Android & Cross-Platform Mobile Apps 0
OSchriever Auf onClick-Listener reagieren und Parameter übergeben (Android Studio) Android & Cross-Platform Mobile Apps 4
W Variable überschreiben (Android Studio) Android & Cross-Platform Mobile Apps 2
ruutaiokwu Android Warum muss man bei Android Studio immer 2x auf "Run" klicken damit die App auf dem Gerät startet Android & Cross-Platform Mobile Apps 8
ruutaiokwu Wie fügt man bei Android Studio .jar-Libraries zu einem Android-Java-Projekt hinzu? Android & Cross-Platform Mobile Apps 33
M Komponenten positionieren in Android Studio 3.6.3 Android & Cross-Platform Mobile Apps 1
M Android Studio - Property-Fenster einblenden Android & Cross-Platform Mobile Apps 1
M Android Studio - App auf dem Smartphone testen Android & Cross-Platform Mobile Apps 7
M Android Studio - Configuration fehlt Android & Cross-Platform Mobile Apps 20
M Unsupported class file major version 57 - Fehlermeldung bei Android Studio Android & Cross-Platform Mobile Apps 27
ruutaiokwu Android Studio (SDK) ANDROID_SDK_ROOT-Variable? Android & Cross-Platform Mobile Apps 5
J Android Studio macht seltsame Sachen Android & Cross-Platform Mobile Apps 2
J Android 9.1 aber android Studio findet API22 Android & Cross-Platform Mobile Apps 0
Dimax Web-Seite in native app convertieren mit Android Studio Android & Cross-Platform Mobile Apps 8
A Android Studio: while-Schleife beginnt nicht Android & Cross-Platform Mobile Apps 5
lolcore android studio: fehler bei laden des emulators Android & Cross-Platform Mobile Apps 10
A Android-Studio: 2. Layout nach kurzer Zeit aufzeigen Android & Cross-Platform Mobile Apps 2
A jpg wird im Android Studio nicht akzeptiert Android & Cross-Platform Mobile Apps 3
J Android Studio - ArrayList - Selected Item ermitteln Android & Cross-Platform Mobile Apps 13
A Android Studio: ImageView verpixelt Android & Cross-Platform Mobile Apps 2
J intend Service im Android Studio Android & Cross-Platform Mobile Apps 4
T Fehler Android Studio: java.net.MalformedURLException: no protocol: http%3A%2F%2Fwww.mal ..... Android & Cross-Platform Mobile Apps 2
Arif Android Android Studio: Fehler beim Einbinden fremder Bibliothek? Android & Cross-Platform Mobile Apps 2
A Android Studio - App mit Nearby Android & Cross-Platform Mobile Apps 1
Jackii Android Android Studio Error im Testlauf ohne zu programmieren Android & Cross-Platform Mobile Apps 9
B Android Probleme mit Android Studio Android & Cross-Platform Mobile Apps 6
H Android Andoid Studio Error (AVD) Android & Cross-Platform Mobile Apps 1
E Wie erhalte ich Zugriff auf das Microfon? (Android Studio) Android & Cross-Platform Mobile Apps 9
L Android Android Studio - Exportierte APK funktioniert nicht Android & Cross-Platform Mobile Apps 6
A Beginnen mit Serverkommunikatsion in Android Studio Android & Cross-Platform Mobile Apps 6
E Android Studio Android & Cross-Platform Mobile Apps 15
L Android Android Studio Setup killt Explorer Android & Cross-Platform Mobile Apps 3
J Variable in strings.xml (Android Studio) Android & Cross-Platform Mobile Apps 0
B Android Android Studio lässt PC abstürzen Android & Cross-Platform Mobile Apps 3
Light Lux Fehlermeldung unter Android Studio Android & Cross-Platform Mobile Apps 1
A Android Android Studio Emulator Problem Android & Cross-Platform Mobile Apps 1
S Android Studio Bluetooth App Problem Android & Cross-Platform Mobile Apps 6
Maresuke Android Android Studio & Bitbucket Android & Cross-Platform Mobile Apps 0
S Software-Tastatur des Android-Studio-Emulators öffnen? Android & Cross-Platform Mobile Apps 0
S Android Studio Emulator falsch eingestellt? Android & Cross-Platform Mobile Apps 1
N Blackscreen bei while-Schleife? (Android-Studio) Android & Cross-Platform Mobile Apps 2
S Android Studio MySql Daten in Listview mit sub Item Android & Cross-Platform Mobile Apps 11
S Android studio, SSH an Raspberry Android & Cross-Platform Mobile Apps 14
H Android Android Studio mit NDK ünterstützung, wann? Android & Cross-Platform Mobile Apps 1
T Android MSSQL Verbindung herstellen - Android Studio Android & Cross-Platform Mobile Apps 2

Ähnliche Java Themen

Neue Themen


Oben