Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Sep 29th, 2005, 11:47 PM   #1
mike111
Newbie
 
Join Date: Sep 2005
Posts: 1
Rep Power: 0 mike111 is on a distinguished road
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!
mike111 is offline   Reply With Quote
Old Sep 29th, 2005, 11:50 PM   #2
Benoit
Expert Programmer
 
Benoit's Avatar
 
Join Date: Sep 2004
Location: Ontario, Canada
Posts: 579
Rep Power: 5 Benoit is on a distinguished road
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
Benoit is offline   Reply With Quote
Old Sep 30th, 2005, 1:40 AM   #3
coldDeath
Expert Programmer
 
coldDeath's Avatar
 
Join Date: Aug 2005
Location: UK
Posts: 862
Rep Power: 4 coldDeath is on a distinguished road
Send a message via AIM to coldDeath Send a message via Yahoo to coldDeath
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.
coldDeath is offline   Reply With Quote
Old Sep 30th, 2005, 2:32 AM   #4
xavier
Professional Programmer
 
xavier's Avatar
 
Join Date: Oct 2004
Location: .ro
Posts: 406
Rep Power: 5 xavier is on a distinguished road
Send a message via Yahoo to xavier
// 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 !
xavier is offline   Reply With Quote
Old Sep 30th, 2005, 3:06 AM   #5
coldDeath
Expert Programmer
 
coldDeath's Avatar
 
Join Date: Aug 2005
Location: UK
Posts: 862
Rep Power: 4 coldDeath is on a distinguished road
Send a message via AIM to coldDeath Send a message via Yahoo to coldDeath
I stand corrected.
__________________
Join us at #programmingforums @ irc.freenode.net!

My software never has bugs. It just develops random features.
coldDeath is offline   Reply With Quote
Old Sep 30th, 2005, 4:12 AM   #6
bl00dninja
Programming Guru
 
bl00dninja's Avatar
 
Join Date: Oct 2004
Location: namespace std
Posts: 1,246
Rep Power: 6 bl00dninja is on a distinguished road
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.
bl00dninja is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:18 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC