ICSE Class 10 · Computer Applications (Java) · Slab and bill programs 2027

Slab programs in ICSE Java: bills, discounts, tax and courier charges, tested at every boundary.

Slab programs in ICSE Java turn a rate card into an if-else ladder: units, amounts or weights fall into bands, and each band has its own rate. They are a favourite shape for the class-based Section B question, and they are lost on two things: reading the slab the wrong way, and testing nothing at the edges. This page explains the two kinds of slab, then solves four original programs in board format, an electricity bill, a discount, a tax and a courier charge, each run in Java 21 at every boundary.

Live online · four slab classes in board format · variable description tables · every boundary run in Java · first class free

Start here

Courses where slab programs are practised

The ICSE Java course where the mini batch writes and marks a slab class most weeks, the Class 11 and 12 Computer Science course where the same decision logic carries into ISC programs, and the data structures course for students who want to test code as carefully as they write it.

Ans. The short version

Slab programs in ICSE Java calculate a charge from a rate card divided into bands, such as an electricity bill by units, a discount by purchase amount, a tax by income or a courier charge by weight. There are two kinds: a bracket slab applies one rate to the whole amount, and a band slab charges each band at its own rate and adds them. They are written with if-else-if ladders inside a class with accept, compute and display methods and a variable description table. Modern Age Coders teaches them live in a Tuesday and Wednesday mini batch in India, or one to one at the family's time.

Q1. What is a slab program, and how many kinds are there?

Slab programs ICSE Java: the two ways a rate card can be read

A slab program works out a charge when the rate changes from one band of values to the next. Before writing any code, decide which of two kinds the question describes, because the same table of rates gives very different answers.

PointBracket slab (whole amount)Band slab (band by band)
How the rate is usedFind the one band the value falls in; that rate applies to the entire valueEach band is charged at its own rate; the parts are added
Typical wording"Purchase amount 3001 to 6000: discount 15%""First 100 units at 2.00, next 200 units at 3.50"
Usual examplesDiscount, commission, grade, fine categoryElectricity and water bills, tax, parcel weight steps
Code shapeif (amt <= 1000) rate = 5; else if ... then one multiplicationEach branch adds the full charge of the lower bands to the part above
At a boundaryThe total can jump down: a bigger amount can cost lessThe total rises smoothly; there is never a jump

The words that decide it

"First", "next", "for every unit above" and "remaining" mean band slab. "If the amount is between" or "on the total purchase" means bracket slab.

The cost of guessing

With the electricity rates below, 450 units billed as a bracket (all units at 5.00, plus the meter charge) gives 2300.0. Read correctly, band by band, it is 1700.0.

What the paper asks for

A class with named data members, a method to accept input, one to calculate and one to display, and a main that creates an object and calls them. A variable description table earns its own credit.

If-else ladders that pick a menu option rather than a rate have their own page: ICSE Class 10 menu-driven programs. Past papers that set a slab class in Question 3 are summarised on ICSE Computer Applications previous year papers, solved.

Q2. How is an electricity bill program written for ICSE?

Electricity bill program in Java, in ICSE board format

An electricity bill is the classic band slab. Each branch of the ladder adds the full charge of every lower band, worked out once by hand, to the units above the last boundary at the new rate.

Question 1. Define a class ElectricBill with data members name (String), units (int) and bill (double). Write void accept() to input the name and units, void calculate() to compute the bill from the tariff below, and void print() to display the name, units and bill. A fixed meter charge of 50 is added to every bill, and a surcharge of 2.5% is added if the total exceeds 3000. Write main to create an object and call the methods.

UnitsRate per unitFull charge of this bandCharge of all bands up to here
First 1002.00200200
Next 200 (101 to 300)3.50700900
Next 300 (301 to 600)5.0015002400
Above 6006.25openopen
ElectricBill.javaband slab, if-else-if ladder
import java.util.Scanner;
class ElectricBill {
    String name;    // consumer's name
    int units;      // units consumed
    double bill;    // amount payable

    void accept() {
        Scanner sc = new Scanner(System.in);
        System.out.print("Consumer name: ");
        name = sc.nextLine();
        System.out.print("Units consumed: ");
        units = sc.nextInt();
    }

    void calculate() {
        double charge;
        if (units <= 100)
            charge = units * 2.00;
        else if (units <= 300)
            charge = 200 + (units - 100) * 3.50;
        else if (units <= 600)
            charge = 900 + (units - 300) * 5.00;
        else
            charge = 2400 + (units - 600) * 6.25;
        bill = charge + 50;
        if (bill > 3000)
            bill = bill + bill * 2.5 / 100;
    }

    void print() {
        System.out.println("Name: " + name);
        System.out.println("Units: " + units);
        System.out.println("Bill: " + bill);
    }

    public static void main(String args[]) {
        ElectricBill ob = new ElectricBill();
        ob.accept();
        ob.calculate();
        ob.print();
    }
}

200, 900 and 2400 come straight from the last column of the tariff table. Work them out on rough paper first; writing the arithmetic inside the ladder is where most slips happen.

VariableTypePurpose
nameStringconsumer's name
unitsintunits consumed
billdoublefinal amount payable
chargedoubleenergy charge before meter charge and surcharge
scScannerreads the input
obElectricBillthe object created in main
Units enteredWhy this inputBill printed
100top of band 1250.0
101first unit of band 2253.5
300top of band 2950.0
450middle of band 31700.0
600top of band 32450.0
680band 4, total just under 30002950.0
800surcharge applies3792.5
Sample runJava 21
Consumer name: Asha Menon
Units consumed: 800
Name: Asha Menon
Units: 800
Bill: 3792.5

The surcharge is worked on the bill after the meter charge is added, because the question says "if the total exceeds 3000".

Step for 800 unitsWorkingValue
Branch chosen800 is above 6004th
Units above 600800 − 600200
charge2400 + 200 × 6.253650.0
Add meter charge3650 + 503700.0
Surcharge, since 3700 > 30003700 × 2.5 / 10092.5
bill3700 + 92.53792.5

Q3. How are discount and tax programs different?

Discount program ICSE and a tax slab: if else programs in board format

A discount is usually a bracket slab: find the one rate and apply it to the whole purchase. A tax is a band slab like the electricity bill, but here it is written a second way, by peeling off one band at a time, which is shorter when there are many bands.

Question 2. Define a class BookFair with data members name (String), type (char, M for member or N for non-member), amount, disc and net (double). Write a default constructor, void input(), void compute() to find the discount on the whole amount from the table below and the net amount, and void display() to print the name, amount, discount and net amount on one line. Write main.

Purchase amountMember discountNon-member discount
Up to 10005%nil
1001 to 300010%5%
3001 to 600015%8%
Above 600020%12%
BookFair.javabracket slab with a type
import java.util.Scanner;
class BookFair {
    String name;     // buyer's name
    char type;       // 'M' member, 'N' non-member
    double amount;   // value of books bought
    double disc;     // discount in rupees
    double net;      // amount to pay

    BookFair() {
        name = "";
        type = 'N';
        amount = 0.0;
        disc = 0.0;
        net = 0.0;
    }

    void input() {
        Scanner sc = new Scanner(System.in);
        System.out.print("Name: ");
        name = sc.nextLine();
        System.out.print("Member (M) or non-member (N): ");
        type = Character.toUpperCase(sc.next().charAt(0));
        System.out.print("Purchase amount: ");
        amount = sc.nextDouble();
    }

    void compute() {
        int rate;
        if (amount <= 1000)
            rate = (type == 'M') ? 5 : 0;
        else if (amount <= 3000)
            rate = (type == 'M') ? 10 : 5;
        else if (amount <= 6000)
            rate = (type == 'M') ? 15 : 8;
        else
            rate = (type == 'M') ? 20 : 12;
        disc = amount * rate / 100;
        net = amount - disc;
    }

    void display() {
        System.out.println(name + "\t" + amount + "\t" + disc + "\t" + net);
    }

    public static void main(String args[]) {
        BookFair b = new BookFair();
        b.input();
        b.compute();
        b.display();
    }
}

One ladder for the amount, and a ternary inside each branch for the type, keeps the program to four branches instead of eight. Character.toUpperCase lets a lower-case m work too.

InputLine printed (name, amount, discount, net)
M, 1000Riya Sen 1000.0 50.0 950.0
M, 1001Riya Sen 1001.0 100.1 900.9
M, 3000Dev Joshi 3000.0 300.0 2700.0
M, 3001Dev Joshi 3001.0 450.15 2550.85
n, 7200Kavya Iyer 7200.0 864.0 6336.0

Look at the first two rows: buying one rupee more costs 49.10 less. That jump is normal for a bracket slab and is a good check that the program has read the table as the question intends. In the actual output the four values are separated by tabs.

VariableTypePurpose
name, typeString, charbuyer and membership
amount, disc, netdoublepurchase, discount and amount payable
rateintdiscount percentage chosen
sc, bScanner, BookFairinput reader and the object

Question 3. Define a class IncomeTax with data members name (String), income and tax (double), a parameterised constructor, void compute() and void display(). The tax is charged band by band: the first 2,50,000 nil, the next 2,50,000 at 5%, the next 5,00,000 at 15% and the rest at 25%, and a surcharge of 3% is then added to the tax. (These rates are invented for practice; they are not any government's rates.)

IncomeTax.javaband slab by peeling
import java.util.Scanner;
class IncomeTax {
    String name;      // taxpayer's name
    double income;    // annual taxable income
    double tax;       // tax including surcharge

    IncomeTax(String n, double i) {
        name = n;
        income = i;
        tax = 0.0;
    }

    void compute() {
        double rest = income;   // income not yet taxed
        double band;            // the part falling in one slab

        band = Math.min(rest, 250000);      // slab 1: nil
        rest = rest - band;

        band = Math.min(rest, 250000);      // slab 2: 5%
        tax = tax + band * 0.05;
        rest = rest - band;

        band = Math.min(rest, 500000);      // slab 3: 15%
        tax = tax + band * 0.15;
        rest = rest - band;

        tax = tax + rest * 0.25;            // slab 4: 25%
        tax = tax + tax * 3 / 100;          // surcharge 3%
    }

    void display() {
        System.out.println("Name: " + name);
        System.out.println("Income: " + income);
        System.out.println("Tax: " + Math.round(tax * 100) / 100.0);
    }

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        System.out.print("Name: ");
        String n = sc.nextLine();
        System.out.print("Annual income: ");
        double i = sc.nextDouble();
        IncomeTax ob = new IncomeTax(n, i);
        ob.compute();
        ob.display();
    }
}

Math.min takes as much of the remaining income as fits in the band. Once rest reaches 0, every later band adds 0, so no if is needed at all.

Income enteredTax before surchargeTax printed
24000000.0
5000001250012875.0
82000012500 + 48000 = 6050062315.0
160000012500 + 75000 + 150000 = 237500244625.0
VariableTypePurpose
name, income, taxString, double, doubletaxpayer, income and tax payable
restdoubleincome still to be taxed
banddoublepart of the income in the current slab
n, iString, doubleinputs passed to the constructor

Both styles are correct for a band slab. The ladder with fixed totals, as in the electricity bill, is what most mark schemes show; the peeling style is shorter when there are five or more bands.

Q4. What about "for every 500 g or part thereof"?

Courier charge program: switch for the zone, Math.ceil for the weight steps

"Or part thereof" means any extra weight, however small, is charged as a full step. Math.ceil of the extra weight divided by the step size, written with a double, gives exactly that number of steps.

Question 4. Define a class Courier with data members weight (int, in grams), zone (char), express (char) and charge (double). Write void accept(), void compute() and void display(). The first 500 g costs 40, 60 or 90 for zone L (local), S (state) or N (national); every further 500 g or part costs 20, 30 or 45 respectively. Express delivery adds 25% to the charge. For any other zone, print "Invalid zone". Write main.

Courier.javaswitch plus a step slab
import java.util.Scanner;
class Courier {
    int weight;      // parcel weight in grams
    char zone;       // 'L' local, 'S' state, 'N' national
    char express;    // 'Y' or 'N'
    double charge;   // amount payable

    void accept() {
        Scanner sc = new Scanner(System.in);
        System.out.print("Weight in grams: ");
        weight = sc.nextInt();
        System.out.print("Zone (L/S/N): ");
        zone = Character.toUpperCase(sc.next().charAt(0));
        System.out.print("Express (Y/N): ");
        express = Character.toUpperCase(sc.next().charAt(0));
    }

    void compute() {
        int first, extra;
        switch (zone) {
            case 'L': first = 40; extra = 20; break;
            case 'S': first = 60; extra = 30; break;
            case 'N': first = 90; extra = 45; break;
            default:
                System.out.println("Invalid zone");
                charge = 0;
                return;
        }
        int steps = 0;
        if (weight > 500)
            steps = (int) Math.ceil((weight - 500) / 500.0);
        charge = first + steps * extra;
        if (express == 'Y')
            charge = charge * 1.25;
    }

    void display() {
        System.out.println("Weight " + weight + " g, zone " + zone + ", charge " + charge);
    }

    public static void main(String args[]) {
        Courier c = new Courier();
        c.accept();
        c.compute();
        c.display();
    }
}

Dividing by 500.0, not 500, is essential: (1250 / 500) in int arithmetic is 2, and Math.ceil of 2 is still 2, so one step would never be charged.

Weight, zone, expressExtra stepsCharge printed
500, L, N040.0
501, L, N1 (1 g is a part)60.0
1000, S, N190.0
1750, N, Y3, then × 1.25281.25
2300, S, Y4, then × 1.25225.0
800, X, NnoneInvalid zone, then charge 0.0
VariableTypePurpose
weightintparcel weight in grams
zone, expresschardelivery zone and express choice
chargedoubleamount payable
first, extraintrates for the first 500 g and each further step
stepsintnumber of further 500 g steps
sc, cScanner, Courierinput reader and the object

Math.ceil and the other syllabus Math methods, with their return types, are on Math library methods for ICSE. Classes with private data and checking methods, the next step up from these, are on encapsulation and access specifiers.

Q5. How do you make sure a slab program earns all 15 marks?

Conditional statements ICSE Class 10: a checklist for slab questions

A Section B question is worth 15 marks, and the mark scheme rewards a correct class structure, correct input, correct logic and correct output. Most marks lost on slab programs are lost at a boundary or in a missing piece of structure.

  1. Copy the names exactly

    Use the class, data member and method names from the question, with the same types and capital letters. A renamed method can cost marks even when it works.

  2. Decide bracket or band, in writing

    Write "whole amount" or "band by band" above the rate table on your rough work, then the band totals if it is a band slab.

  3. Check every boundary sign

    "Up to 100" is <= 100; "above 600" is > 600; "1001 to 3000" in an else-if after <= 1000 needs only <= 3000.

  4. Keep the fraction

    Use double for money, and write percentages as * rate / 100 on a double, or divide by 100.0. An int division can silently turn a 5% discount into zero.

  5. Do the extras in the stated order

    A fixed charge, then a surcharge on the total, is not the same as a surcharge first. Follow the wording of the question line by line.

  6. Test the edges, not the middle

    Dry run one value at the top of each band and one just above it. If those agree with the rate table, the middle values will too.

  7. Finish the paperwork

    A main that creates the object and calls every method, comments on the data members, and a variable description table.

Quick check questions

  1. Write the condition for "units from 201 to 400, both included", as one boolean expression.
    Answer units >= 201 && units <= 400. Inside an else-if ladder that has already handled units <= 200, units <= 400 is enough.
  2. With the ElectricBill tariff, what is the bill for 250 units?
    Answer 200 + 150 × 3.50 = 725, plus 50 is 775.0.
  3. Why does disc = amount * (rate / 100); give 0 when rate is an int below 100?
    Answer rate / 100 is int division, so 15 / 100 is 0 before it is multiplied. Write amount * rate / 100 with amount a double, or rate / 100.0.
  4. How many 500 g steps does Math.ceil give for 1501 g after the first 500 g?
    Answer 3. The extra weight is 1001 g, and 1001 / 500.0 is 2.002, which rounds up to 3.0.

The same marking habits apply to every Section B family on ICSE Class 10 Java programs practice, and loop-based programs are on loop programs in Java for ICSE.

Q6. How does the mini batch practise slab programs?

From rate card to tested class in one week

Slab programs reward slow reading and quick testing. The week is split so that Tuesday is spent on reading rate cards and Wednesday on writing and marking a full class.

  1. Read the card aloud

    At the Tuesday 5:30 PM IST class students get three fresh rate cards and say, for each, whether it is a bracket or band slab and what the band totals are, before any code.

  2. Guess the boundary outputs

    For each card the group predicts the charge at the top of each band and one unit above it, then the teacher runs the program in BlueJ on a shared screen.

  3. Write the class by hand

    On Wednesday at 8:00 PM IST each student writes a full slab class with its variable description table, on paper, against the clock.

  4. Marked on screen

    Answers are marked against a board-style scheme in front of the group, so every lost mark has a named reason.

  5. Into the lab file and the mocks

    Good solutions go into the student's laboratory assignments for internal assessment, and slab classes come back in timed mock papers from December.

The lab file side of this work is described on the ICSE project and internal assessment page.

Batch or personalised: you choose

Practise slab programs in the mini batch, or one to one

The rate cards, the boundary tests and the board-style marking are identical in both formats. Families in India pick the fixed evening group of six or fewer, or a private slot; ICSE students abroad are taught one to one. Billing is monthly and there is no admission fee.

Option 1 · Fixed batch timings

Mini batch, Tuesday 5:30 PM and Wednesday 8 PM

₹2,999

per month, two live classes a week

  • Tuesday 5:30 PM and Wednesday 8:00 PM IST, live
  • Six ICSE Class 10 students at most
  • Fresh rate cards read and classified every Tuesday
  • A full slab class written and marked on Wednesday
  • Boundary outputs checked in BlueJ on a shared screen
Book a free demo in this batch

Option 2 · Choose your own timing

Personalised one to one

₹4,999

per month, one private class a week, at a time set with you

  • A slot the family chooses, in India or overseas
  • Extra practice on whichever slab kind confuses your child
  • School homework slab questions worked through together
  • Timed full Section B answers as the board exam nears
  • Same teachers and the same 2027 syllabus
Ask for a personalised plan

A student who writes slab programs that run but keeps misreading the rate card or missing a boundary often needs only a few one to one sessions. A student who is still building confidence with classes, loops and Strings as well is better served by the steady two classes a week of the batch. Fees appear in your own currency.

Studying outside India?

Slab program practice for ICSE students abroad

Students at ICSE schools in the Gulf, Singapore and further away write the same Section B classes in the same 2027 paper. Outside India the practice is one to one, at an after-school hour in the student's time zone.

Where you liveTime differenceUsual class window, local timeFormat
India (IST)
every Indian city
ISTTue 5:30 PM, Wed 8:00 PMMini batch or 1-on-1
United Arab Emirates
Dubai, Sharjah
1 h 30 min behind India3:00 PM to 9:00 PMPersonalised 1-on-1
Indonesia and Thailand
West Java, Bangkok area
1 h 30 min ahead of India3:30 PM to 9:00 PMPersonalised 1-on-1
Singapore
Singapore
2 h 30 min ahead of India3:30 PM to 9:00 PMPersonalised 1-on-1

The slot is chosen after the free demo and can move around school exams. How classes work for families overseas is explained on ICSE Computer Applications classes in the Gulf and abroad.

What families say

Rated 4.9 across 547 Google reviews

Real reviews from real families. We neither write nor commission them.

★★★★★

"The one step solution for my son. Modern Age Coders make learning coding so simple that kids love it. The teachers explain complex concepts clearly with practical exercises and interactive content."

Ria Mukherjee

Parent

★★★★★

"Modern Age Coders has been a game-changer for me. I struggled to grasp IT concepts and coding before joining, but their classes transformed everything. I can now confidently write complex programs with ease."

Samriddha Mondal

Student

★★★★★

"One of the most wonderful education centres out there. Education is not limited to school syllabus but focuses on skill development."

Vansh Agarwal

Student

★★★★★

"My child Dhairya is really enjoying the Modern Age Coders classes. This is his first online class and he eagerly looks forward to it. I can already see his improvement, and the teachers are very cooperative."

Sonam Oswal

Parent of Dhairya

★★★★★

"Modern Age Coders have wonderful teachers who teach in a clear, easy and practical way. The teacher boosts students' confidence and inspires them to learn without hesitation."

Sonu Goyal

Parent

★★★★★

"I highly recommend this computer coding class! The teachers are incredibly knowledgeable and passionate about coding."

Ritu Kedia

Parent

The rest of the Class 10 series

More pages for Class 10 board students

Every page in the ICSE Class 10 Computer Applications series, grouped by what you need: classes, each chapter, Section B programs, question practice, notes and revision, and the exam itself.

CBSE Class 10 AI (417): The Mon and Wed 9 PM AI batch CBSE AI 417 syllabus explained CBSE AI important questions Sample paper and mock tests

Questions about slab programs

What students ask about slab and bill programs in ICSE

What is a slab program in Java ICSE?

A slab program calculates a charge when the rate changes from one range of values to the next, such as an electricity bill where the first 100 units cost less per unit than the next 200. It is written with an if-else-if ladder, or sometimes switch, usually inside a class with methods to accept, compute and display.

How do you write an electricity bill program in Java for ICSE?

Create a class with name, units and bill as data members, and methods to accept input, calculate and print. In the calculate method, use an if-else-if ladder: each branch adds the full charge of all lower bands, worked out beforehand, to the units above the last boundary multiplied by the new rate. Then add any fixed charge or surcharge the question states.

What is the difference between a slab rate on the whole amount and band by band?

With a whole-amount slab, you find the one range the value falls in and apply that rate to all of it, as in most discount questions. With a band-by-band slab, each part of the value is charged at the rate of its own band and the parts are added, as in electricity bills and tax.

How do you write a discount program in ICSE Java?

Read the purchase amount and any customer type, use an if-else-if ladder on the amount to choose the discount percentage, then compute discount = amount * rate / 100 and net = amount - discount. If the rate also depends on a type, a ternary or a nested if inside each branch keeps the ladder short.

Are slab programs asked in the ICSE Computer Applications board exam?

Class-based programs with a slab or rate table have appeared in Section B in several recent papers, usually as the question on class and object. The 2027 specimen paper is not yet confirmed, so treat slab programs as a very likely shape rather than a promise, and practise the other families too.

How do you calculate a charge "for every 500 g or part thereof" in Java?

Work out the extra weight beyond the first slab, divide it by the step size as a double and apply Math.ceil, then cast to int: steps = (int) Math.ceil((weight - 500) / 500.0). Dividing by 500 as an int would cut off the part step before ceil could round it up.

Should I use if-else or switch for slab programs?

Use if-else-if for ranges, because switch can only compare one value against fixed constants. switch suits a choice such as a zone letter or a category number. Many good answers use both: switch to pick the rates for a category, then if-else or a formula for the amount.

What are conditional statements in ICSE Class 10?

They are statements that choose what to run based on a condition: if, if-else, the if-else-if ladder, nested if, the ternary operator and switch-case. The ICSE syllabus covers them in Class 9 and the Class 10 paper re-tests them, most visibly in slab, menu-driven and number-checking programs.

Do I need a variable description table in an ICSE slab program?

It is expected in the laboratory assignments for internal assessment and is good practice in the board paper. List every variable, its data type and its purpose. Students often include it in Section B answers as well, and it helps the examiner follow your logic.

Do you teach slab and bill programs in live classes?

Yes. In the ICSE mini batch on Tuesday at 5:30 PM IST and Wednesday at 8:00 PM IST, students classify rate cards, predict boundary outputs and write a full slab class that is marked against a board-style scheme. Personalised one to one classes are also available at a time the family picks.

Start

Try a free live slab program class

In the free demo your child reads a fresh rate card, decides whether it is charged on the whole amount or band by band, predicts the bill at two boundaries and then sees the program run in BlueJ. Afterwards you get a frank view of what needs work and whether the mini batch or one to one suits better.

Prefer to read more first? See ICSE Computer Applications important questions or the ICSE Class 10 Java classes.

WhatsApp us · +91 91233 66161 · connect@modernagecoders.com

Every class is live video. The form requests a callback and reserves nothing.

We call within a few hours. No card, no enrolment fee.

Want it sooner? Book a priority demo

A full live class of about 45 to 60 minutes at a slot you pick, with a written skill report and learning roadmap on WhatsApp afterwards. The fee is adjusted against your first month if you enrol.

Book a priority demo

Keep exploring Modern Age Coders

By class and age

Learn more

Free resources

From the blog

Start here