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

- I need the chegg expert to follow exactly what the instructions are asking for

ID: 669726 • Letter: #

Question

- I need the chegg expert to follow exactly what the instructions are asking for so that i can learn this material.
-the code needs to be writte in Java
- thank you for your help

CSIS 1410 - Lab Printer Create a class called PrinterApp as well as the following three classes as specified in the class diagrams Notice that the class name Printer and its method print are spelled in italic This indicates that Printer is an abstract class and print is an abstract method Printer serialNumber int + constructorw Printer (number: int) + prind () + toString ( String LaserPrinter InkietPrinte e int + constructor» InkjetPrinter sNumber : int ) remaining Toner int +*constructor» LasserPrinter (sNumber int) +getRermainingT oner() int +print remainn : int + gotRemainingCartridge ( + print ) Ad Printer: Printer is an abstract class and print is an abstract method. The method toString returns a string of the following form className #idNumber (eg. InkjetPrinter #1234567 or LaserPrinter #2345678) Ad LaserPrinter / InkjetPrinter: In the constructor do the following: . Set the value of remainingToner/ remain ingCartridge to 100 (100% full when new) and initialize the base class In method print do the following a) If the field remainingToner/remainingCartridge is greater 0 then it reduces the value of the field by 10. It also prints a message that informs the user that the printer is printing and how much toner/cartridge is left. e.g. : LaserPrinter is printing. Remaining toner: 90% If the field is O print a message that the toner/cartridge is empty. Do NOT subtract anything from 0 b) Ad PrinterApp: InkjetPrinter #1234567 Remaining cartridge: 100% Try to create an instance of Printer. What happens? Create an instance of InkjetPrinter Print the instance LaserPrinter #2345678 Remaining Toner : 100% . Print how much cartridge is remaining Create an instance of LaserPrinter Print the instance Array of Printers InkjetPrinter #1234567 InkjetPrinter is printing. Remaining cartridge: 90% InkjetPrinteris printing. Remaining cartridge: 88% . Print how much toner is remaining . Print a label "Array of Printers: " · Create an array of printers and initialize it with the two LaserPrinter #2345678 LaserPrinter is printing. Remaining toner: 90% LaserPrinter is printing. Remaining toner: 80% printer instances you just created User a foreach loop to loop through all the printers Print the instance, make the printer print twice, print an empty line

Explanation / Answer

public class PrinterApp
{
public static void main(String[] args){
   //Printer p=new Printer(1234567); cannot be created
   InkjetPrinter ip=new InkjetPrinter(1234567);
   System.out.println(ip);
   System.out.println("Remaining Catridge: "+ip.remainingCatridge+"%");
   LaserPrinter lp=new LaserPrinter(2345678);
   System.out.println(lp);
   System.out.println("Remaining Toner: "+lp.remainingToner+"%");
   System.out.println("Array of printers:");
   Printer[] p = new Printer[2];
   p[0]=ip;
   p[1]=lp;
   for(Printer k:p){
       k.print();
       k.print();
       System.out.println("");
   }
}
}

public class InkjetPrinter extends Printer{
  
   int remainingCatridge;

   public InkjetPrinter(int sNumber) {
       super(sNumber);
       remainingCatridge=100;
       // TODO Auto-generated constructor stub
   }

   @Override
   public void print() {
       if(remainingCatridge>0){
           remainingCatridge=remainingCatridge-10;
           System.out.println("CatridgePrinter is printing. Remaining Catridge: "+remainingCatridge+"%");
       }else{
           System.out.println("Catridge is empty.");
       }
      
   }
}

public abstract class Printer{
   private int serialNumber;
   public Printer(int number){
       serialNumber=number;
   }
   public abstract void print();
   public String toString(){
       return this.getClass().getName()+" #"+serialNumber;
   }
}

public class LaserPrinter extends Printer{
  
int remainingToner;
   public LaserPrinter(int number) {
       super(number);
       remainingToner=100;
       // TODO Auto-generated constructor stub
   }
public int getRemainingToner(){
   return remainingToner;
}
   @Override
   public void print() {
       if(remainingToner>0){
           remainingToner=remainingToner-10;
           System.out.println("LaserPrinter is printing. Remaining toner: "+remainingToner+"%");
       }else{
           System.out.println("Toner is empty.");
       }
      
   }
}