| | |
Need help with decimal program.
Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Nov 2008
Posts: 29
Reputation:
Solved Threads: 4
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;
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;
Last edited by arghasen; Jul 26th, 2009 at 4:03 am.
Argha Sen
Ask and it will be opened for u
Ask and it will be opened for u
The problem can be easiely solved by ROUNDING the output number to a certain degree.
edit ::
Here is my version of your code...
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.
C++ Syntax (Toggle Plain Text)
#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...
C++ Syntax (Toggle Plain Text)
#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.
Last edited by djextreme5; Jul 26th, 2009 at 2:03 pm.
![]() |
Similar Threads
- 8086, hex to decimal program (Assembly)
- Binary (12 digit max) to Decimal/Integer (C++)
- Ending a program... (C++)
- Mr (Assembly)
- I dont know what mistake I did (C++)
- HomeWork help with classes. Plz. (C++)
- CAn any1 tell me watz wrong in da code (C++)
Other Threads in the C++ Forum
- Previous Thread: About default constructor...
- Next Thread: Including Header Files in a C++ GUI
Views: 261 | Replies: 3
| Thread Tools | Search this Thread |
Tag cloud for C++
6 api application array arrays assignment beginner binary bitmap c++ c/c++ calculator char class classes code coding compile compiler console conversion convert count data database delete developer display dll email encryption error file forms fstream function functions game generator getline givemetehcodez graph homeworkhelper iamthwee ifstream image input int java lazy lib loop looping loops map math matrix memory multidimensional multiple newbie news node number output parameter pointer problem program programming project proxy python random read recursion recursive reference return sort sorting string strings struct template templates text tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets





