Google PlusFacebookTwitter

Structures – Customer Bill

By on Mar 23, 2007 in On A Whim | 0 comments

Share On GoogleShare On FacebookShare On Twitter

/* Copyright (C) 2007 Ankur Banerjee. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1 as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. http://www.fsf.org/licensing/licenses/lgpl.html */

/* Structures – Program to manipulate bills */

#include <iostream.h>
#include <conio.h>
#include <stdio.h>

struct cust
{
int num, units;
char name[50];
float net;
} c[5];

void main()
{
clrscr();
for (int i=0; i<5; i++)
{
cout<<endl<<“Enter data for customer “<<i+1<<endl
<<“Enter customer number : “;
cin>>c[i].num;
cout<<“Enter customer name : “;
gets(c[i].name);
cout<<“Enter the number of units consumed : “;
cin>>c[i].units;
if (c[i].units <= 100)
c[i].net = 0.4 * c[i].units;
else if ((c[i].units > 100) && (c[i].units <= 200))
c[i].net = (c[i].units – 100) * 0.5 + 40;
else if ((c[i].units > 200) && (c[i].units <= 300))
c[i].net = (c[i].units – 200) * 0.75 + 90;
else if (c[i].units > 300)
c[i].net = (c[i].units – 300) + 165;
}
for (int j=0; j<5; j++)
{
cout<<endl<<“Data for customer “<<j+1<<endl
<<“Customer number : “<<c[j].num<<endl
<<“Customer name : “<<
puts(c[j].name);

cout<<“Number of units consumed : “<<c[j].units<<endl
<<“Total bill : “<<c[j].net<<endl;
}
getch();
}

/* Output */

Enter data for customer 4
Enter customer number : 53
Enter customer name : Arthur Dent
Enter the number of units consumed : 256

Data for customer 1
Customer number : 53
Customer name : Arthur Dent
Number of units consumed : 256
Total bill : 132



Submit a Comment

Your email address will not be published. Required fields are marked *