You are on page 1of 4

FEU INSTITUTE OF TECHNOLOGY

Computer Programming Lab


//program that buy 3 books with discount of 50 if VIP, where the city address is the today's special city.

#include<iostream>

#include<cstring>

using namespace std;

double compute(double book[3][2]);

struct discount

int vip;

char xplace[10];

};

int main(void){

double book[3][2];

char city[10], member;

int i, j, price,discounts;

struct discount d ;

d.vip = 50;

cout << "Enter place with Discount today: " ;

cin >> d.xplace;

cout << "\n\nEnter 3 Books ";


for(int i = 0; i < 3; ++i){

cout << "\nEnter Book[" << i + 1 << "] ID: ";

cin >> book[i][0];

for(int j = 1; j < 2; ++j){

cout << "Enter Book[" << i + 1 << "] amount[" << j << "]: ";

cin >> book[i][j];

price = compute(book);

cout << "\n\nEnter City: ";

cin >> city;

if (strcmp(d.xplace,city) == 0){

discounts = d.vip;

else{

discounts = 0;

cout << "\nThe Subtotal: " << price;

cout << "\nThe Total Discount is: " << discounts;

cout << "\nTotal Amount is: " << price - discounts;

return 0;

}
double compute(double book[3][2]){

double price = 0;

for(int i = 0; i < 3; ++i){

for(int j = 1; j < 2; ++j){

price = price + book[i][j];

return price;

You might also like