本文介绍了如何计算包含消费税和消费税总额的总金额?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想计算包含GST和支付的GST总额的总金额。
现在我想计算总支付金额,包括消费税和消费税总额。但我无法这样做,因为我已将价格变量声明为私有。什么是计算总价格和支付的商品及服务税总额的替代方案。
我的尝试:
I want to calculate the Total amount including GST and Total GST paid.
Now I want to calculate the Total amount including GST and Total GST paid. But I am unable to do so as I have declared price variable as private. what is an alternative to calculate Total Price and Total amount of GST paid.
What I have tried:
#include<iostream.h>
#include<conio.h>
int T;
class item
{
int quantity;
char name[100];
float price;
public:
float Total;
void get_data();
void put_data();
};
void item::get_data()
{
cout<<"Enter the name of the item "<<T+1<<" = ";
cin>>name;
cout<<"Enter the quantity= ";
cin>>quantity;
cout<<"Enter the price= ";
cin>>price;
cout<<"\n";
}
void item::put_data()
{
cout<<"\n"<<name<<"\t\t "<<quantity<<"\t\t "<<price<<"\t\t\t"<<"SR";
}
void main()
{
int N;
clrscr();
cout<<"Enter the Total number of item = ";
cin>>N;
item i[100];
for(T=0;T<N;T++)
{
i[T].get_data();
}
cout<<"\nName of items";
cout<<"\t\tQuantity ";
cout<<"\titem price ";
cout<<"\t\tGST ";
for(T=0;T<N;T++)
{
i[T].put_data();
}
//Total amount including GST= ?
//Total amount GST paid=?
Now I want to calculate the Total amount including GST and Total GST paid. But I am unable to do so as I have declared price variable as private. what is an alternative to calculate Total Price and Total amount of GST paid.
getch();
}
推荐答案
class item
{
// ...
public:
int getQuantity() const { return quantity; }
float getPrice() const { return price; }
const char* getName() const { return name; }
};
这篇关于如何计算包含消费税和消费税总额的总金额?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!