![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Sep 2005
Posts: 1
Rep Power: 0
![]() |
Help with c++ program
Hello, I am doing a assignment for my class.
My assignment is tying to tell how much book subscriptions sold. Here is the code: // This program find out how much each subscriptions cost #include <iostream> #include <iomanip> using namespace std; int main() { float A, A1, B, B1, C1, Total, Total1, Total2, Total3; cout << "Enter the cost profit for A Level: "; cin >> A; cout << "Enter the high school % earn for A Level: "; cin >> A1; cout << "Enter the cost profit for B Level: "; cin >> B; cout << "Enter the high school % earn for B Level: "; cin << B1; cout >> "Enter the cost profit for C Level: "; cin << C; cout >> "Enter the high school % earn for C Level: "; cin << C1; Total = A + A1; Total1 = B + B1; Total2 = C + C1; Total3 = Total + Total1 + Total2; cout << "\nSubscriptions profit\n"; cout << "-------------\n"; cout << "Level A subscriptions profit: " << showpoint << Total << endl; cout << "Level B subscriptions profit: " << Total1 << endl; cout << "Level C subscriptions profit: " << Total2 << endl; cout << "Total profit: " << Total3 << endl; return 0; } When the person open the program, I want them to enter the number into "Total profit" and "Total % of school earn" questions. After I want the codes to add, so I could get an equal amount. The program said that I have 6 errors. I think I wrote it right, but the program disagree. Can anyone here tell me what I did wrong? Does anyone here understand what I'm tying do? Thank you! |
|
|
|
|
|
#2 |
|
Expert Programmer
Join Date: Sep 2004
Location: Ontario, Canada
Posts: 574
Rep Power: 5
![]() |
I don't know C++, but I think some of your >> and << are pointing in the wrong directions
![]()
__________________
Johnny was a chemist's son but Johnny is no more, for what Johnny thought was H2O was H2SO4 |
|
|
|
|
|
#3 |
|
Expert Programmer
|
No they are perfectly fine.
I think this line is wrong: cout << "Level A subscriptions profit: " << showpoint << Total << endl; There isnt a variable called showpoint.
__________________
Join us at #programmingforums @ irc.freenode.net! My software never has bugs. It just develops random features.
|
|
|
|
|
|
#4 |
|
Professional Programmer
|
// This program find out how much each subscriptions cost
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
float A, C, A1, B, B1, C1, Total, Total1, Total2, Total3;
cout << "Enter the cost profit for A Level: ";
cin >> A;
cout << "Enter the high school % earn for A Level: ";
cin >> A1;
cout << "Enter the cost profit for B Level: ";
cin >> B;
cout << "Enter the high school % earn for B Level: ";
cin >> B1;
cout << "Enter the cost profit for C Level: ";
cin >> C;
cout << "Enter the high school % earn for C Level: ";
cin >> C1;
Total = A + A1;
Total1 = B + B1;
Total2 = C + C1;
Total3 = Total + Total1 + Total2;
cout << "\nSubscriptions profit\n";
cout << "-------------\n";
cout << "Level A subscriptions profit: " << showpoint << Total << endl;
cout << "Level B subscriptions profit: " << Total1 << endl;
cout << "Level C subscriptions profit: " << Total2 << endl;
cout << "Total profit: " << Total3 << endl;
system("pause");
}Benoit was right :p try to pay more attention !! you had 'cin <<' insted of 'cin >>' , and cout was also reversed on the last 2 -- you were also missing C variable . Oh .. what is showpoint ?
__________________
Don't take life too seriously, it's not permanent ! |
|
|
|
|
|
#5 |
|
Expert Programmer
|
I stand corrected.
__________________
Join us at #programmingforums @ irc.freenode.net! My software never has bugs. It just develops random features.
|
|
|
|
|
|
#6 |
|
Programming Guru
![]() Join Date: Oct 2004
Location: namespace std
Posts: 1,246
Rep Power: 6
![]() |
a 2-second google said basically "showpoint" as correctly used by the op is a formatting thing that forces the decimal point in a floating point number to be shown. pretty intuitive once you see what it is.
all of us that didn't know what it was are like "does that plot a graph or some shit!?!" :p i however, sincerely doubt that the function was worth including another library for.
__________________
i put on my robe and wizard hat... Have you ever heard of Plato, Aristotle, Socrates?...Morons. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|