import java.util.Scanner;
Public class bank
{
Public static double interest=2.65;//interest
Public void rise ()
{
Interest=interest + 0.5;
}
Public static void main (String [] args)
{
Bank pool=new bank ();
System. The out. Println (" the current interest rates for bank death "+ interest +" % ");
System. The out. Println (" please enter the deposit ");
Scanner sc=new Scanner(System.in);
Double num=sc. NextDouble ();
System. The out. Println (" please enter the deposit term ");
Double year=sc. NextDouble ();
Double sum1=num;
For (int I=1; i<=year; I++)
{
Num=num + ((num/100) * 2.65);
}
System. The out. Println (" five years later, in 20000 dollars for that obtained "+ (num - sum1));
}
}
CodePudding user response:
Public class T6 {
Public static void main (String [] args) {
Double x1=1.126;
System. Out. Println (the String. Format (. % 2 f, the x1));
DecimalFormat df=new DecimalFormat (" 00 ");
System. The out. Println (df) format (x1));
}
}
CodePudding user response:
The String. Format (" % 2 f ", num - sum1)But easy to lose accuracy was calculated by the int directly, suggest using Bigdecimal
CodePudding user response:
Ok, Bigdecimal is???CodePudding user response: