ApexSensei

Drills Apex basics

For loop: number invoices

A for loop has three parts: a start, a test, and a step.

Your task

Use a counting for loop to number three invoices, then run the loop again with zero invoices.

Integer invoiceCount = 3;
Integer numbered = 0;

// Case A: number three invoices

// Case B: no invoices this time
invoiceCount = 0;
numbered = 0;

Requirements

  1. Invoice: INV-1, Invoice: INV-2, Invoice: INV-3 should be printed in order
  2. Numbered count: 3 should be printed
  3. Zero count: 0 should be printed
  4. for loop should be used that counts up to invoiceCount
  5. for loop should be run again for Case B
  6. INV-1 should be built from the counter

Sign in to open this drill