Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I\'ve got the following code in Java and need to break out the file using classe

ID: 3886498 • Letter: I

Question

I've got the following code in Java and need to break out the file using classes, objects, and object-oriented programming. I need to modify this class and create a main program to instantiate that class; the main program should call the methods of that class to do the work. Can someone help me fix this.

package creditlimitcalc;

import java.awt.*;
import java.util.Scanner;

public class CreditLimitCalc
{
    public static void main(String[] args)
    {
        String creditStatusString;
        int accNo, begBal, itemChargedPerMon, creditPerMon, creditLimit, newBalance;
        Scanner input=new Scanner(System.in);
        System.out.println("Enter the account no.:");
        accNo=input.nextInt();
        System.out.println("Enter the balance in the begining of the month.:");
        begBal=input.nextInt();
        System.out.println("Enter the total of all items charged by the customer this month.:");
        itemChargedPerMon=input.nextInt();
        System.out.println("Enter the total of all credits applied to the customer.:");
        creditPerMon=input.nextInt();
        System.out.println("Enter the allowed credit limit.:");
        creditLimit=input.nextInt();
      
        newBalance = begBal + itemChargedPerMon - creditPerMon;
      
        if (newBalance > creditLimit)
            creditStatusString = "Credit Limit Exceeded";
        else
            creditStatusString = "Credit Report";
        System.out.println("New Balance is " + newBalance);
        System.out.print(creditStatusString);
        System.exit(0);
    }
}

Explanation / Answer

The below will be the class breakouts  for creditlimitcalc

package creditlimitcalc;

import java.util.Scanner;

public class CreditLimitCalc

{

String creditStatusString;

int accNo, begBal, itemChargedPerMon, creditPerMon, creditLimit, newBalance;

public void CreditLimitCalcFun()

{

Scanner input=new Scanner(System.in);

System.out.println("Enter the account no.:");

accNo=input.nextInt();

System.out.println("Enter the balance in the begining of the month.:");

begBal=input.nextInt();

System.out.println("Enter the total of all items charged by the customer this month.:");

itemChargedPerMon=input.nextInt();

System.out.println("Enter the total of all credits applied to the customer.:");

creditPerMon=input.nextInt();

System.out.println("Enter the allowed credit limit.:");

creditLimit=input.nextInt();

newBalance = begBal + itemChargedPerMon - creditPerMon;

if (newBalance > creditLimit)

creditStatusString = "Credit Limit Exceeded";

else

creditStatusString = "Credit Report";

System.out.println("New Balance is " + newBalance);

System.out.print(creditStatusString);

System.exit(0);

}

}

And below will be the main class to call the above class by creating its object and the object then calls the function of the above class creditlimitcalc.

package creditlimitcalc;

public class MainProgram {

public static void main(String[] args)

{

CreditLimitCalc obj = new CreditLimitCalc();

obj.CreditLimitCalcFun();

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote