我不太确定我的代码在哪里导致导致错误计算的问题.当我运行该程序时,会出现以下警告:
C4305:'argument':从'double'截断到'float'.
税额(ta)和总成本(tc)似乎有问题,
Current Output:
Cost before Tax: $30.20
Tax Amount: $30.20
Total Cost: $-107374144.00
ground beef is ex-sponged
Press any key to continue . .
What it **should** be:
Your item name:ground beef
Cost before Tax: $30.20
Tax Amount: $2.64
Total Cost: $32.84
ground beef is ex-sponged
Run Code Online (Sandbox Code Playgroud)
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<iomanip>
#include<string>
using namespace std;
class item
{
public:
item(char* = " " ,float=0.0,int=0,float=0.0);
~item();
void print();
void calc(int);
private:
char name[20];
int quan;
float cost, tp, cbt, tax, …Run Code Online (Sandbox Code Playgroud) c++ ×1