hi so könnte mir jeamnd sagen was bei mir im code nicht stimmt . ich meine
da stimmt einiges nicht . ich habe die Formel aus einem Javascript HTML oroginal hab unten mit angehängt !
nur wes ich nicht genau wie ich sie umänder bzw. richtig anpasse würde mich freunen wenn mir da jemand helfen könnte
würde mich freunen wenn mir jemand dabei hilft es richtig umzuwandeln.
main.XML
1<?xml version="1.0" encoding="utf-8"?>
2<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 android:orientation="vertical"
4 android:layout_width="fill_parent"
5 android:layout_height="fill_parent">
6
7
8<EditText
9 android:hint="Gebe eine Zahl ein"
10 android:id="@+id/EditTextZAHL"
11 android:layout_width="fill_parent"
12 android:layout_height="wrap_content"
13 android:numeric="decimal">
14
15
16</EditText>
17
18
19<Button
20 android:text="Berechne....."
21 android:id="@+id/ButtonRECHNE"
22 android:layout_width="fill_parent"
23 android:layout_height="wrap_content">
24</Button>
25
26
27<TextView
28 android:text="Ergebnis"
29 android:id="@+id/TextViewERGEBNIS"
30 android:layout_width="fill_parent"
31 android:layout_height="wrap_content">
32</TextView>
33
34</LinearLayout>
1package com.example.calcu;
2
3import android.app.Activity;
4import android.os.Bundle;
5import android.view.View;
6import android.view.View.OnClickListener;
7import android.widget.Button;
8import android.widget.EditText;
9import android.widget.TextView;
10
11public class Calcu extends Activity
12 implements OnClickListener{
13 /** Called when the activity is first created. */
14
15
16
17 private Button ButtonRECHNE;
18 private EditText EditTextZAHL;
19 private TextView TextViewERGEBNIS;
20
21
22
23
24
25 @Override
26 public void onCreate(Bundle savedInstanceState) {
27 super.onCreate(savedInstanceState);
28 setContentView(R.layout.main);
29
30
31 ButtonRECHNE = (Button) findViewById(R.id.ButtonRECHNE);
32 EditTextZAHL = (EditText) findViewById(R.id.EditTextZAHL);
33 TextViewERGEBNIS = (TextView) findViewById(R.id.TextViewERGEBNIS);
34
35
36
37
38 ButtonRECHNE.setOnClickListener(this);
39
40 }
41
42
43 @Override
44 public void onClick(View v) {
45
46 var a = -1.00844494413448 * Math.pow(10, -12);
47 var b = 1.2356986230482 * Math.pow(10, -8);
48 var c = -5.94771172066112 * Math.pow(10,-5);
49 var d = 0.139443656834417;
50 var e = -156.936920229832;
51 var f = 68836.3;
52
53if(EditTextZAHL.length == 4 && EditTextZAHL <= 3000 && EditTextZAHL >= 1500)
54 {
55 jQuery('#TextViewERGEBNIS').text(Math.round(a * Math.pow(EditTextZAHL, 5) + b * Math.pow(EditTextZAHL,4) + c * Math.pow(EditTextZAHL,3) + d * Math.pow(EditTextZAHL,2) + e * EditTextZAHL + f));
56 }
57 else
58 {
59 jQuery('#TextViewERGEBNIS').text("zahl zwischen 1500 und 3000");
60 }
61{
62
63
64
65
66 TextViewERGEBNIS.setText("Ergebnis: " + TextViewERGEBNIS);
67
68
69 }
70}
original JAVASCRIPT
1<script type="text/javascript">
2function isNumber(n)
3{
4return !isNaN(parseFloat(n)) && isFinite(n);
5}
6
7function calc_conq(pr) {
8var a = -1.00844494413448 * Math.pow(10, -12);
9var b = 1.2356986230482 * Math.pow(10, -8);
10var c = -5.94771172066112 * Math.pow(10,-5);
11var d = 0.139443656834417;
12var e = -156.936920229832;
13var f = 68836.3;
14
15
16
17if(pr.length == 4 && pr <= 3000 && pr >= 1500)
18{
19jQuery('#cp').text(Math.round(a * Math.pow(pr, 5) + b * Math.pow(pr,4) + c * Math.pow(pr,3) + d * Math.pow(pr,2) + e * pr + f));
20}
21else
22{
23jQuery('#cp').text("zahl zwischen 1500 und 3000");
24}
25}
26jQuery(document).ready(function () {
27
28jQuery('#personal').keyup(function () {
29
30calc_conq(jQuery('#personal').val());
31
32});
33});
Empfohlener redaktioneller Inhalt
Mit Deiner Zustimmung wird hier ein externer Inhalt geladen.
Mit Klick auf den oben stehenden Button erklärst Du Dich damit einverstanden, dass Dir externe Inhalte angezeigt werden dürfen. Dabei können personenbezogene Daten an Drittanbieter übermittelt werden. Mehr Infos dazu findest Du in unserer Datenschutzerklärung.