2016-07-01 7 views
-3

Ich bin neu in der Programmierung, und ich fragte mich, ob ich etwas Hilfe bekommen könnte. Mein Programm läuft nicht mehr unter System.out.println("To calculate interest, we need three values. the first is the percent of interest. The second is the time the interest has to be applied for. The third is the amount of money the interest is being applied on.");. Ich bin offen für jeden Vorschlag. Bitte zeigen Sie auch etwas anderes falsch mit diesem Programm. Vielen Dank!Programm stoppt am Anfang meines Programms

Antwort

0

Entfernen Sie alle zusätzlichen Klammern; Sie sind außerhalb Ihrer main Methode.

public static void main(String[] args) 

{ 

    System.out.println("To calculate interest, we need three values. the first is the percent of interest. The second is the time the interest has to be applied for. The third is the amount of money the interest is being applied on."); 

// } <-- remove 

// { <-- remove 

    System.out.println("Please enter your percent of interest in a decimal format: "); 

// -----SKIP----- 

// } <-- remove 

// { <-- remove 
    System.out.println("Your interest is $" + answer + "."); 

    System.out.println("Your total payment is $" + (answer + amount) + "."); 
} // leave this here (end of method) 
+0

sorry bout askin dumme fragen bc ich bin wirklich neu in der Programmierung, aber wie bekomme ich das Programm zu fördern? Die erste Anweisung wird angezeigt, aber sie fährt nicht fort, aber das Programm läuft noch. Irgendein Rat? –

+0

@DanielLonarkar Es wartet wahrscheinlich auf Eingaben. – shmosel

+0

Ich gebe es ein, aber es tut nichts. –

0

Sie schreiben Instanz Blöcke und in Hauptmethode, nicht wahr Objekt creation.instance Blöcke ausgeführt werden, wenn Sie Objekt erstellen von class.if Sie jene Instanz Block ausführen möchten Sie YourClass myclass = new YourClass() in der Haupt schreiben sollte Methode und wenn Sie die Hauptfunktion ausführen, werden diese Blöcke außerhalb von main() ausgeführt ODER Sie sollten diese Blöcke wie das @ shmosel-Beispiel in der Hauptmethode schreiben.

Verwandte Themen