import javax.swing.*;
public class TimeDeposit{
  public static void main(String[] args){
  String choice1, choice2,monthlySales,income;
  int value1, value2;
  // to display value of a variable
  DecimalFormat num=new DecimalFormat(",###.00");
  JOptionPane.showMessageDialog(null,"Monthly Sales In $","Bank", JOptionPane.INFORMATION_MESSAGE);
  JOptionPane.showMessageDialog(null,"the Interest is 0.025"num.format(monthlySales)+"income is"+num.format(income),"Bank", JOptionPane.INFORMATION_MESSAGE);
  choice1=JOptionPane.showInputDialog("The time less than: ");
  value1=Integer.parseInt(choice1);
  
  choice2=JOptionPane.showInputDialog("The deposit is greater than: ");
  value2=Integer.parseInt(choice2);
  
  switch(value1){
  case 1:
  JOptionPane.showMessageDialog(null,"the Interest is 0.025","Bank", JOptionPane.INFORMATION_MESSAGE);
  break;
  case 2:
  if(value2>=24){
  JOptionPane.showMessageDialog(null,"the Interest is 0.030","Bank", JOptionPane.INFORMATION_MESSAGE);
  }else{
    JOptionPane.showMessageDialog(null,"No Interest service for your input","Bank", JOptionPane.INFORMATION_MESSAGE);
	}
  break;
  case 3:
  if(value2>36){
  JOptionPane.showMessageDialog(null,"the Interest is 0.035","Bank", JOptionPane.INFORMATION_MESSAGE);
  }else{
    JOptionPane.showMessageDialog(null,"No Interest service for your input","Bank", JOptionPane.INFORMATION_MESSAGE);
	}
  break;
  case 4:
  if(value2>48){
  JOptionPane.showMessageDialog(null,"the Interest is 0.045","Bank", JOptionPane.INFORMATION_MESSAGE);
  }else{
    JOptionPane.showMessageDialog(null,"No Interest service for your input","Bank", JOptionPane.INFORMATION_MESSAGE);
  }
  break;
  case 5:
  if(value2>60){
  JOptionPane.showMessageDialog(null,"the Interest is 0.0475","Bank", JOptionPane.INFORMATION_MESSAGE);
  }else{
    JOptionPane.showMessageDialog(null,"No Interest service for your input","Bank", JOptionPane.INFORMATION_MESSAGE);
	}
  break;
  default:
  JOptionPane.showMessageDialog(null,"No Interest service for you","Bank", JOptionPane.INFORMATION_MESSAGE);
  break;
  }
 }
}

this my assignment

my mentor told me a condition of having 2 decimal places only and calculate it with the rate per certain year

can someone help me please

You need to add the following import to use "DecimalFormat":

import java.text.*;

Line #9: add "+" between 0.025 and num.format(monthlySales)
Line #9: num.format requires a number not a string

If monthlySales is declared as String, you need to covert to a number before passing it to format.

String monthlySales
num.format(Double.parseDouble(monthlySales))

Otherwise, if you declare monthlySales as a double you can leave it as is:

double monthlySales
num.format(monthlySales)

line #11 and 14: Are you sure you want these to be integers?
Maybe double:

double value1
value1 = Double.parseDouble(choice1)

Is this supposed to be a console program? If so, you might want to use "java.io.BufferedReader" or "java.util.Scanner" for input. And for output, use "System.out.print" or "System.out.println".

This article has been dead for over six months. Start a new discussion instead.