Can someone help me with this please.

import java.util.Scanner;
import java.text.NumberFormat;


public class ChargeAccount
{
  
    private int additional_charges;
    public int balance;
    private  double min_payment;
    private int interest;
    private double new_balance;
    
    //initialise Charge Account
    public ChargeAccount(int previous_balance, int add_charges);
   
    {
    balance = previous_balance;
    additional_charges =  add_charges;
      
    Scanner scan = new Scanner (System.in);
    System.out.print ("Previous Balance: ");
    previous_balance = scan.nextInt();
    
    Scanner scan = new Scanner (System.in);
    System.out.print ("Additional Charges: ");
    add_charges = scan.nextInt();
    
    
    
}
      
    // Calculate Interest
    public int calculateInterest();
    {
   if(balance > 0)
   interest = (balance + additional_charges) * 0.02;
   return interest;
    }
 
    //Calculate New Balance
 public void calNewBal()
    {
    new_balance = previous_balance + calculateInterest() + add_charges;
}

   
     // Calcualte Minimum Payment  
   public double minPayment()
   {
      if(new_balance<50)
      {
      min_payment =new_balance;
    }
    
        else if(new_balance>50 && new_balance <300)
     {
        min_payment=50; 
    }
    
         else 
         {
         min_payment = new_balance * 0.02;
    }
    return min_payment;
}

 
 

NumberFormat money = NumberFormat.getCurrencyInstance();


   System.out.println ("CS CARD International Statement");
   System.out.println ("================================");
   System.out.println();
   System.out.println ("Balance: " + money.format(balance));
   System.out.println ("Balance: " + money.format(additional_charges));
   System.out.println ("Interest: " + money.format(calculateInterest));
   System.out.println ("New Balance: " + money.format(new_balance));
   System.out.println ("Minimum Payment: " + money.format (min_payment));

}

Edited 6 Years Ago by Nick Evan: added code tags

There is a lot of errors in your code:
The declaration of the class must not be terminated by “;”
The variable scan is declared twis
The declaration of the constructor must not be terminated with “;”
You assign a double value to an int value so you have to cast it to int wish cause a missing of precision
The variable new_balance is not declared
The variable add_charges is not declared
There is 8 instruction outside a function

The possible code could be as following:
I have added a default constructor and a method that i called printResult ;

public class ChargeAccount
{

    private int additional_charges;
    public int balance;
    private  double min_payment;
    private int interest;
    private double new_balance;
    private int previous_balance;
    private int add_charges;

    //initialise Charge Account
    public ChargeAccount(int previous_balance, int add_charges)/*;*/

    {
    balance = previous_balance;
    additional_charges =  add_charges;

    Scanner scan = new Scanner (System.in);
    System.out.print ("Previous Balance: ");
    previous_balance = scan.nextInt();

    //Scanner scan = new Scanner (System.in);
    System.out.print ("Additional Charges: ");
    add_charges = scan.nextInt();



}

    ChargeAccount() {

    }

    // Calculate Interest
    public int calculateInterest()/*;*/
    {
   if(balance > 0)

   //loss of precision
       interest = (int) ((balance + additional_charges) * 0.02);
   return interest;
    }

    //Calculate New Balance
 public void calNewBal()
    {
    new_balance = previous_balance + calculateInterest() + add_charges;
}


     // Calcualte Minimum Payment
   public double minPayment()
   {
      if(new_balance<50)
      {
      min_payment =new_balance;
    }

        else if(new_balance>50 && new_balance <300)
     {
        min_payment=50;
    }

         else
         {
         min_payment = new_balance * 0.02;
    }
    return min_payment;
}




NumberFormat money = NumberFormat.getCurrencyInstance();

public void printResult(){
   System.out.println ("CS CARD International Statement");
   System.out.println ("================================");
   System.out.println();
   System.out.println ("Balance: " + money.format(balance));
   System.out.println ("Balance: " + money.format(additional_charges));
   System.out.println ("Interest: " + money.format(calculateInterest()));
   System.out.println ("New Balance: " + money.format(new_balance));
   System.out.println ("Minimum Payment: " + money.format (min_payment));
}
}

Hope this help.

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