correct my mistakes and please make this program executable

Que Generate software for a garment shop at Treasure Island where a monsoon offer is going on.the offer
states as below
1. On the purchase of one item, bill amount will be of actual printed price(No offer)
2. On the purchase of two items, bill amount will be of the item having the higher price.
3. On the purchase of three items, bill amount will be the sum of highest and lowest price.
Create a class SHOP having three overloaded methods named billAmount()……..{with parameter with
return type.}
Create another class containing main method and generate the bill for above given situations





My Code


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

class Shop
{
private:
int item;
float price,p1,p2,p3;

public:
float billAmount(float p);
float billAmount(float p,float x);
float billAmount(float p,float x,float y);
};
float Shop::billAmount(float p)
{
price=p;
item=1;
cout<<"no offer on the purchase of 1 item,cost:"<<price;
return (price);
}
float Shop::billAmount(float p,float x)
{
p1=p;
p2=x;
item=2;
if(p1>p2)
{
cout<<"On the purchase of two items, bill amount will be of the item having the higher price.cost:"<<p1;
return (p1);
}
else
{
cout<<"On the purchase of two items, bill amount will be of the item having the higher price.cost:"<<p2;
return (p2);
}
}
float Shop:: billAmount(float p,float x,float y)
{
p1=p;
p2=x;
p3=y;
item=3;
if(p1>p2 && p1>p3)
{
if(p2<p3)
{
float n=p1+p2;
cout<<"On the purchase of 3 items, bill amount will be of the item having the sum of lower and higher price.cost:"<<n;
return (n);
}
else
{
float n=p1+p3;
cout<<"On the purchase of 3 items, bill amount will be of the item having the sum of lower and higher price.cost:"<<n;
return (n);
}
}
else if(p3>p1 && p3>p2)
{
if(p1<p2)
{
float n=p1+p3;
cout<<"On the purchase of 3 items, bill amount will be of the item having the sum of lower and higher price.cost:"<<n;
return (n);
}
else
{
float n=p2+p3;
cout<<"On the purchase of 3 items, bill amount will be of the item having the sum of lower and higher price.cost:"<<n;
return (n);
}
}
else if(p2>p1 && p2>p3)
{
if(p1<p3)
{
float n=p1+p2;
cout<<"On the purchase of 3 items, bill amount will be of the item having the sum of lower and higher price.cost:"<<n;
return (n);
}
else
{
float n=p2+p3;
cout<<"On the purchase of 3 items, bill amount will be of the item having the sum of lower and higher price.cost:"<<n;
return (n);
}
}
class Ti:Shop
{
void main()
{
clrscr();
Shop s;
s.billAmount(1421.9);
s.billAmount(1930,2020);
s.billAmount(1502,2004,9125);
getch();
}
}
[code] "Please use code tags" [/code]
http://www.cplusplus.com/forum/articles/40071/#msg218019

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <iostream> //note not .h
//I'll suggest you to not use conio. You aren't giving it a good use either way

class Shop //¿what is this class for?
{
private:
  //int item;
  //float price,p1,p2,p3; //you don't seem to use them
//...
};
float Shop::billAmount(float p)
{
  price=p;
  item=1; //it seems that you don't care about the state of you object.
  std::cout<<"no offer on the purchase of 1 item,cost:"<<price; //this shouldn't be here. Ditto for all the other methods
  return (price);
}

class Ti:Shop //¿private inheritance?
{
  void main() //this ain't java. 
  {
    clrscr();  //Don't touch my screen
    Shop s;
    s.billAmount(1421.9);
    s.billAmount(1930,2020);
    s.billAmount(1502,2004,9125);
    getch(); //If you finish then finish
  }
}

int main(){ //starting point of the program
  //...
}
Last edited on
the program is giving following errors

Compiling TI.CPP:
Error TI.CPP 101: Declaration terminated incorrectly
Error TI.CPP 101: Declaration missing ;
Error TI.CPP 101: Compound statement missing }
Warning TI.CPP 101: Function should return a value
Topic archived. No new replies allowed.