Daniel Lonarkar - 1 year ago 55
Java Question

Program Stops at the Beginning of My Program

i am new to programming, and i was wondering if i could get some help. My program stops running at

`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.");`
. I am open to any suggestion. Also, please point out anything else wrong with this program. Thanks!

``````import java.util.Scanner;

public class Interest

{

double userInput;

double interest;

double time;

double amount;

Scanner myScanner = new Scanner(System.in);

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.");

}

{

userInput = myScanner.nextDouble();

if(myScanner.hasNextDouble())

{

interest = userInput;

}

else

{

}

}

{

System.out.println("Please enter the time the interest is applied for: ");

userInput = myScanner.nextDouble();

if(myScanner.hasNextDouble())

{

time = userInput;

}

else

{

System.out.println("Please enter an integer for the time the interest is applied for.");

}

}

{

System.out.println("Please enter your amount of money that the interest is applied to: ");

userInput = myScanner.nextDouble();

if(myScanner.hasNextDouble())

{

amount = userInput;

}

else

{

System.out.println("Please enter an integer for the amount of money that the interest is applied to.");

}

}

{

answer = (amount * interest * time);

}

{

}

}
``````

Get rid of all the extra braces; they're outside your `main` method.

``````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