I made this program that should be very easy but it does not work.
When I try to run it, it should take the price and add tax to it but it comes up with a crazy decimal number like: 7.74335e+268.
What should I do I tried everything.

I #include everything so sorry about the long text.

Attachments
#include <cstdio>
#include <cstdlib>
#include <process.h>
#include <conio.h>
#include <iostream>
#include <fstream>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include <string.h>
#include <windows.h>
using namespace std;
string str;

int main(int nNumberofArgs, char* pszArgs[]) {
//Coding starts here//
double P; //Product price//
double T = 0.07; //Tax for product//
double TP; //Total price after tax//
double TA; //Tendered//
double M; //Misc//
string choice; //After calc choice//

bridge: //The bridge of the program//
cout <<"                *------------------------------------------------*\n"
     <<"                | Welcome To The Automated Cash Register Program |\n"
     <<"                *------------------------------------------------*\n\n";
cout <<"Product price $";
cin >> P;
P*T==TP; //Calculates product price with tax *Here is the problem*//
cout <<"Total price $"<<TP<<endl;
cout <<"Out of $";
cin >> TA;
M==TP-TA;
cout <<"Change due $"<<M<<endl;
invalid:
cout <<"\n Type 'q' and hit enter to quit,\n"
     <<"or type 'c'and hit enter to continue: ";
cin >> choice;
if(choice=="q") {
return 0; }

if(choice=="c") {
system("CLS");
goto bridge; }

else {
cout <<"Invalid input, try again.";
goto invalid; }


}

hey your program is solved
next time pls indent properly
just do the changes done in this portion of your code

cout <<"Product price $";

cin >> P;

TP=P*T; //Calculates product price with tax *Here is the problem*//

cout <<"Total price $"<<TP<<endl;

cout <<"Out of $";

cin >> TA;

M=TP-TA;

The problem can be easiely solved by ROUNDING the output number to a certain degree.

#include<iostream>
#include<iomanip>
using namespace std;

int main()
{
	double i = 0.546546, ii = 2.365463847698;

	cout << fixed;
	cout << setprecision(3) << i * ii << endl;

	return 0;
}

edit ::

Here is my version of your code...

#include <cstdio>
#include <cstdlib>
#include <process.h>
#include <conio.h>
#include <iostream>
#include <fstream>
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include <string>
#include <windows.h>
using namespace std;
string str;

int main(int nNumberofArgs, char* pszArgs[]) {
//Coding starts here//
double P; //Product price//
double T = 0.07; //Tax for product//
double TP; //Total price after tax//
double TA; //Tendered//
double M; //Misc//
string choice; //After calc choice//

bridge: //The bridge of the program//
cout <<"                *------------------------------------------------*\n"
     <<"                | Welcome To The Automated Cash Register Program |\n"
     <<"                *------------------------------------------------*\n\n";
cout <<"Product price $";
cin >> P;
TP = (P * T) + P;//Calculates product price with tax *Here is the problem*//
cout <<"Total price $"<<TP<<endl;
cout <<"Out of $";
cin >> TA;
M=TA-TP;
cout <<"Change due $"<<M<<endl;
invalid:
cout <<"\n Type 'q' and hit enter to quit,\n"
     <<"or type 'c'and hit enter to continue: ";
cin >> choice;
if(choice=="q") {
return 0; }

if(choice=="c") {
system("CLS");
goto bridge; }

else {
cout <<"Invalid input, try again.";
goto invalid; }


}

Also, you do not know C++ basics. For example, = and == are different. = Assigns values to a variable and == checks two given conditions for example,.

after executing a if statement like this,

if (var1 = 10)
{}

the var1 variable will hold the value 10...

however, if its like this,

if (var1 == 10)
{}

then it CHECKS the value of var1 to be 10.

This article has been dead for over six months. Start a new discussion instead.