Go Back   Flash Flash Revolution > General Discussion > Chit Chat
Register FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
Old 09-15-2005, 02:38 PM   #1
JurseyRider734
lil j the bad b-word
Retired StaffFFR Veteran
 
JurseyRider734's Avatar
 
Join Date: Aug 2003
Location: nj
Age: 33
Posts: 7,506
Send a message via AIM to JurseyRider734 Send a message via Skype™ to JurseyRider734
Default C++ Help

I need someone who's good at C++ to maybe make me this code. It's probably really basic for someone who's knowledgable about it but I got really confused. I can just check this thread and copy and paste it into there tomorrow.

Programming Project: ProfitMargin

To make a profit, a local store marks up the prices of its items by a certain percentage. Write a C++ program that reads the original price of the item sold, the percentage of the marked-up price, and the sales tax rate. The program then outputs the original price of the item, the percentage of the mark-up, the store's selling price of the item, the sales tax rate, the sales tax, and the final price of the item. (The final price of the item is the selling price plus the sales tax.


Thanks >_>
__________________
Quote:
Originally Posted by Arch0wl
I'd better be considering I own roughly six textbooks on logic and have taken courses involving its extensive use

Quote:
Originally Posted by Afrobean View Post
Quote:
Originally Posted by JurseyRider734
the fact that you're resorting to threatening physical violence says a lot anyway.
Just that you're a piece of shit who can't see reason and instead deserves a fucking beating.
JurseyRider734 is offline   Reply With Quote
Old 09-15-2005, 03:32 PM   #2
lightdarkness
Summer!!
Retired StaffFFR Veteran
 
lightdarkness's Avatar
 
Join Date: Jul 2003
Location: New York
Age: 35
Posts: 11,308
Send a message via AIM to lightdarkness Send a message via MSN to lightdarkness Send a message via Yahoo to lightdarkness Send a message via Skype™ to lightdarkness
Default RE: C++ Help

That isn't C++, that's math

If you're familiar with how to cin and cout stuff, it's really all about knowing what kind of math is involved.

I can't remember how variables are stored in C++, but my first suggestion for you is to take out a sheet of paper, and do one practice input.
__________________
lightdarkness is offline   Reply With Quote
Old 09-15-2005, 04:02 PM   #3
QreepyBORIS
FFR Player
 
QreepyBORIS's Avatar
 
Join Date: Feb 2003
Location: It is a mystery.
Age: 33
Posts: 7,454
Send a message via AIM to QreepyBORIS Send a message via MSN to QreepyBORIS
Default RE: C++ Help

You can use Doubles/Floats and <iomanip.h>'s set preceision function, if you've learned it. The math involved is really easy, unless you have a weird taxation percent in New Jersey.
__________________

Signature subject to change.

THE ZERRRRRG.
QreepyBORIS is offline   Reply With Quote
Old 09-15-2005, 04:08 PM   #4
JurseyRider734
lil j the bad b-word
Retired StaffFFR Veteran
 
JurseyRider734's Avatar
 
Join Date: Aug 2003
Location: nj
Age: 33
Posts: 7,506
Send a message via AIM to JurseyRider734 Send a message via Skype™ to JurseyRider734
Default RE: C++ Help

what.
__________________
Quote:
Originally Posted by Arch0wl
I'd better be considering I own roughly six textbooks on logic and have taken courses involving its extensive use

Quote:
Originally Posted by Afrobean View Post
Quote:
Originally Posted by JurseyRider734
the fact that you're resorting to threatening physical violence says a lot anyway.
Just that you're a piece of shit who can't see reason and instead deserves a fucking beating.
JurseyRider734 is offline   Reply With Quote
Old 09-15-2005, 04:15 PM   #5
soccr743
FFR Player
Retired Staff
 
soccr743's Avatar
 
Join Date: Dec 2003
Posts: 549
Send a message via AIM to soccr743 Send a message via MSN to soccr743 Send a message via Yahoo to soccr743
Default Re: C++ Help

Quote:
Originally Posted by JurseyRider734
To make a profit, a local store marks up the prices of its items by a certain percentage. Write a C++ program that reads the original price of the item sold, the percentage of the marked-up price, and the sales tax rate. The program then outputs the original price of the item, the percentage of the mark-up, the store's selling price of the item, the sales tax rate, the sales tax, and the final price of the item. (The final price of the item is the selling price plus the sales tax.
First off, are you reading this from a file? Or from the command prompt...

Secondly, you need to just know math. Just use the variable type "float" for the variable in this case.

Thirdly, you need to know how to convert from a string or char* to a floating point number. I use my own String class library, so I am not sure if the standard library contains a method for converting strings to integers or floats.

-----Soccr743-----
__________________
soccr743 is offline   Reply With Quote
Old 09-15-2005, 04:18 PM   #6
QreepyBORIS
FFR Player
 
QreepyBORIS's Avatar
 
Join Date: Feb 2003
Location: It is a mystery.
Age: 33
Posts: 7,454
Send a message via AIM to QreepyBORIS Send a message via MSN to QreepyBORIS
Default RE: Re: C++ Help

Why/how on Earth would you go from char/string to a float?
__________________

Signature subject to change.

THE ZERRRRRG.
QreepyBORIS is offline   Reply With Quote
Old 09-15-2005, 04:23 PM   #7
JurseyRider734
lil j the bad b-word
Retired StaffFFR Veteran
 
JurseyRider734's Avatar
 
Join Date: Aug 2003
Location: nj
Age: 33
Posts: 7,506
Send a message via AIM to JurseyRider734 Send a message via Skype™ to JurseyRider734
Default RE: Re: C++ Help

Keep in mind i've been in C++ for a week, and I have no fucking clue what you're talking about. It doesn't matter what the numbers are, i'm just confused with what to put.

The only reason i'm posting is because i'm a day behind in my class. So while everyone is on addictinggames, i'm sitting there confused with this goddamn thing.
__________________
Quote:
Originally Posted by Arch0wl
I'd better be considering I own roughly six textbooks on logic and have taken courses involving its extensive use

Quote:
Originally Posted by Afrobean View Post
Quote:
Originally Posted by JurseyRider734
the fact that you're resorting to threatening physical violence says a lot anyway.
Just that you're a piece of shit who can't see reason and instead deserves a fucking beating.
JurseyRider734 is offline   Reply With Quote
Old 09-15-2005, 04:27 PM   #8
soccr743
FFR Player
Retired Staff
 
soccr743's Avatar
 
Join Date: Dec 2003
Posts: 549
Send a message via AIM to soccr743 Send a message via MSN to soccr743 Send a message via Yahoo to soccr743
Default RE: Re: C++ Help

Qreepy, you read from the console into the buffer which is in char* format... Then, you would need to convert that to a float in order to use it in calculations.

I would talk with you on AIM about it Eva, but I have a boatload of homework and you bloxed meh

-----Soccr743-----
__________________
soccr743 is offline   Reply With Quote
Old 09-15-2005, 04:28 PM   #9
chickendude
Away from Computer
FFR Simfile AuthorFFR Veteran
 
chickendude's Avatar
 
Join Date: Sep 2003
Location: Massachusetts
Age: 33
Posts: 1,901
Send a message via AIM to chickendude
Default RE: C++ Help

I can do C, but I'm guessing its mostly the same except for minor syntactical stuff <_<

Code:
main()
{
 float oprice, taxrate, markup,fprice,sprice,tax;

 printf("print the original price, tax rate percentage, and markup percentage")
 scanf("%f %f %f",&oprice,&taxrate,&markup);

 sprice = oprice * (1 + (markup/100) );
 taxprice = sprice * (1 + taxrate/100);
 fprice = sprice + taxprice;

 printf("original price is %f \n markup is %f \n taxrate is %f \n",oprice,markup,taxrate")
 printf("store price is %f \n sales tax is %f \n final price is %f\n",sprice,tax,fprice");
}
now just change the printfs into couts and scanf into a cin and you win
I don't know the syntax for couts and cin >_<
would someone like to tell me
Is it just the same but with << >> instead of () ?

EDIT:
PS, in C to go from string to int its
stoi(insertstringhere)
and you have to #include <stdlib.h>
and stof for string to float
ftoi, itof, they're all there <_< itos ftos <_<
__________________
chickendude is offline   Reply With Quote
Old 09-15-2005, 04:38 PM   #10
JurseyRider734
lil j the bad b-word
Retired StaffFFR Veteran
 
JurseyRider734's Avatar
 
Join Date: Aug 2003
Location: nj
Age: 33
Posts: 7,506
Send a message via AIM to JurseyRider734 Send a message via Skype™ to JurseyRider734
Default RE: C++ Help

That's COMPLETELY different.

Soccr, I unblocked you a while ago rofl wtg
__________________
Quote:
Originally Posted by Arch0wl
I'd better be considering I own roughly six textbooks on logic and have taken courses involving its extensive use

Quote:
Originally Posted by Afrobean View Post
Quote:
Originally Posted by JurseyRider734
the fact that you're resorting to threatening physical violence says a lot anyway.
Just that you're a piece of shit who can't see reason and instead deserves a fucking beating.
JurseyRider734 is offline   Reply With Quote
Old 09-15-2005, 04:51 PM   #11
chickendude
Away from Computer
FFR Simfile AuthorFFR Veteran
 
chickendude's Avatar
 
Join Date: Sep 2003
Location: Massachusetts
Age: 33
Posts: 1,901
Send a message via AIM to chickendude
Default RE: C++ Help

after getting some rudimentary C++ syntax help <_<

Code:
#include <iostream>
main()
{
 float oprice, taxrate, markup,fprice,sprice,tax;

 cout<<"print the original price, tax rate percentage, and markup percentage";
 cin>>oprice>>taxrate>>markup;

 sprice = oprice * (1 + (markup/100) );
 taxprice = sprice * (1 + taxrate/100);
 fprice = sprice + taxprice;

 cout<<"original price is",oprice;
 cout<<"markup is",markup;
 cout<<"taxrate is",taxrate;
 cout<<"store price is",sprice;
 cout<<"sales tax is",tax;
 cout<<"final price is",fprice;
}
I don't know whether you need to do int main or void main
and also I don't know what lib to include
is it #include <iostream> ?

this should be slightly less way different, I hope <_<

EDIT: Edited in iostream
__________________
chickendude is offline   Reply With Quote
Old 09-15-2005, 05:24 PM   #12
talisman
Resident Penguin
FFR Simfile AuthorFFR Veteran
 
talisman's Avatar
 
Join Date: May 2003
Age: 37
Posts: 4,598
Send a message via AIM to talisman
Default RE: C++ Help

yeah it's <iostream>

chicken's program should work.
talisman is offline   Reply With Quote
Old 09-15-2005, 05:47 PM   #13
soccr743
FFR Player
Retired Staff
 
soccr743's Avatar
 
Join Date: Dec 2003
Posts: 549
Send a message via AIM to soccr743 Send a message via MSN to soccr743 Send a message via Yahoo to soccr743
Default RE: C++ Help

I question this line:

"cin>>oprice,taxrate,markup;"

Seems as though it should be this:

"cin >> oprice >> taxrate >> markup;"

But again, I don't do much work with the console.

-----Soccr743-----
__________________
soccr743 is offline   Reply With Quote
Old 09-15-2005, 05:50 PM   #14
chickendude
Away from Computer
FFR Simfile AuthorFFR Veteran
 
chickendude's Avatar
 
Join Date: Sep 2003
Location: Massachusetts
Age: 33
Posts: 1,901
Send a message via AIM to chickendude
Default RE: C++ Help

Well I don't either, if you're right, then I'll edit it in, so does anyone else know?

EDIT:
I just realized that was soccr speaking so uh <_< I'll go ahead and change that
__________________
chickendude is offline   Reply With Quote
Old 09-15-2005, 06:00 PM   #15
soccr743
FFR Player
Retired Staff
 
soccr743's Avatar
 
Join Date: Dec 2003
Posts: 549
Send a message via AIM to soccr743 Send a message via MSN to soccr743 Send a message via Yahoo to soccr743
Default RE: C++ Help

Hell, me speaking does not mean I am right... Especially when it comes to console programming. I really only did this stuff like a year ago when I first started and have since then moved from SDL to DirectX.

-----Soccr743-----
__________________
soccr743 is offline   Reply With Quote
Old 09-15-2005, 06:32 PM   #16
GuidoHunter
is against custom titles
Retired StaffFFR Veteran
 
GuidoHunter's Avatar
 
Join Date: Oct 2003
Location: Texas
Age: 39
Posts: 7,371
Send a message via AIM to GuidoHunter Send a message via Skype™ to GuidoHunter
Default

I'm somewhat certain that you can't read in several variables in one line, but if you can, Soccr's corrected line is the way to read the input. Otherwise, just have three different lines.

Also, you can directly read in an int, double, char, string, or what have you. chickendude had a pretty good code, but I'd make some modifications to it.

By the way, every program where I had to do it, I went through hell trying to get the program to correctly output decimal values like I wanted (like showing prices with all the necessary trailing zeroes), so if my code for it looks complicated, it is, but it works.

Assuming all the math is correct, this should read everything in properly and output everything you need with correct precision.

Code:
#include <iostream> 
#include <iomanip>

using namespace std;

void main() 
{ 
 double oprice, taxrate, markup, fprice, sprice, tax; 
 
 cout.setf(ios::floatfield | ios::showpoint);
 cout<<setprecision(2);

 cout<<"Input the original price, tax rate percentage, and markup percentage"; 
 cin>>oprice;
 cin>>taxrate;
 cin>>markup; 

 sprice = oprice * (1 + (markup/100) ); 
 taxprice = sprice * (1 + taxrate/100); 
 fprice = sprice + taxprice; 

 cout<<"Original price is $"<<oprice<<endl; 
 cout<<"Markup is $"<<markup<<endl; 
 cout<<"Taxrate is $"<<taxrate<<endl; 
 cout<<"Store price is $"<<sprice<<endl; 
 cout<<"Sales tax is $"<<tax<<endl; 
 cout<<"Final price is $"<<fprice<<endl; 
}
--Guido

http://andy.mikee385.com
__________________

Quote:
Originally Posted by Grandiagod View Post
Quote:
Originally Posted by Grandiagod View Post
She has an asshole, in other pics you can see a diaper taped to her dead twin's back.
Sentences I thought I never would have to type.
GuidoHunter is offline   Reply With Quote
Old 09-15-2005, 06:42 PM   #17
chickendude
Away from Computer
FFR Simfile AuthorFFR Veteran
 
chickendude's Avatar
 
Join Date: Sep 2003
Location: Massachusetts
Age: 33
Posts: 1,901
Send a message via AIM to chickendude
Default RE: C++ Help

Ok, I looked it up, you were right
see soccr, you are always right <_<
__________________
chickendude is offline   Reply With Quote
Old 09-15-2005, 06:48 PM   #18
dancingmaniac3
FFR Player
 
Join Date: Nov 2003
Location: San Antonio...where tortilla is pronounced right.
Posts: 1,873
Send a message via AIM to dancingmaniac3
Default RE: C++ Help

man, i feel so behind because i'm taking a Java/VBNet course.
__________________
dancingmaniac3 is offline   Reply With Quote
Old 09-15-2005, 07:00 PM   #19
JurseyRider734
lil j the bad b-word
Retired StaffFFR Veteran
 
JurseyRider734's Avatar
 
Join Date: Aug 2003
Location: nj
Age: 33
Posts: 7,506
Send a message via AIM to JurseyRider734 Send a message via Skype™ to JurseyRider734
Default

Quote:
Originally Posted by GuidoHunter
I'm somewhat certain that you can't read in several variables in one line, but if you can, Soccr's corrected line is the way to read the input. Otherwise, just have three different lines.

Also, you can directly read in an int, double, char, string, or what have you. chickendude had a pretty good code, but I'd make some modifications to it.

By the way, every program where I had to do it, I went through hell trying to get the program to correctly output decimal values like I wanted (like showing prices with all the necessary trailing zeroes), so if my code for it looks complicated, it is, but it works.

Assuming all the math is correct, this should read everything in properly and output everything you need with correct precision.

Code:
#include <iostream> 
#include <iomanip> (not taught this yet)

using namespace std;

void main() 
{ 
 double oprice, taxrate, markup, fprice, sprice, tax; 
 
 cout.setf(ios::floatfield | ios::showpoint);
 cout<<setprecision(2);  (I have no idea what this stuff is, it wasn't taught, so i'm guessing we can't use it)

 cout<<"Input the original price, tax rate percentage, and markup percentage";  (these have to be on different lines)
 cin>>oprice;
 cin>>taxrate;
 cin>>markup; 

 sprice = oprice * (1 + (markup/100) ); 
 taxprice = sprice * (1 + taxrate/100); 
 fprice = sprice + taxprice; 

 cout<<"Original price is $"<<oprice<<endl; 
 cout<<"Markup is $"<<markup<<endl; 
 cout<<"Taxrate is $"<<taxrate<<endl; 
 cout<<"Store price is $"<<sprice<<endl; 
 cout<<"Sales tax is $"<<tax<<endl; 
 cout<<"Final price is $"<<fprice<<endl; 
}
--Guido

http://andy.mikee385.com

This is somewhat along the lines of it, but the thing is he isn't asking for the Original price, he isn't asking for the markup, he's not asking for the tax rate. He's only asking for the New Price. That is, after markup and taxes.

Here's some formulas I had wrote out on paper in class today:
sellingPrice=originalPrice+addPrice
addPrice=originalPrice*markupPrice
newPrice=?

Like I said, i've only been doing this for a week.

Well here's kind of what it had looked like

"Enter the original price of the item: *random number*

Enter the mark-up percentage: *random number/decimal*

Enter the tax-rate: *random number/decimal*"


There has to be formulas that will calculate the newPrice after it's marked up and taxes are applied.

Such as

oP = 5
markup= .5 (50%)
taxrate= .18 (18% i guess)

After I figured this out, I got completely lost of what I had to enter the rest of the way...

It started out like

int originalPrice
cout<<"Enter the original price of the item. ";
cin>>price;
cout<<endl;
double markupPrice
cout<<Enter the markup price. ";


and so on...

Hope I clarified some things >_> But Guido's looked somewhat close.
__________________
Quote:
Originally Posted by Arch0wl
I'd better be considering I own roughly six textbooks on logic and have taken courses involving its extensive use

Quote:
Originally Posted by Afrobean View Post
Quote:
Originally Posted by JurseyRider734
the fact that you're resorting to threatening physical violence says a lot anyway.
Just that you're a piece of shit who can't see reason and instead deserves a fucking beating.
JurseyRider734 is offline   Reply With Quote
Old 09-15-2005, 07:05 PM   #20
chickendude
Away from Computer
FFR Simfile AuthorFFR Veteran
 
chickendude's Avatar
 
Join Date: Sep 2003
Location: Massachusetts
Age: 33
Posts: 1,901
Send a message via AIM to chickendude
Default

The 'Final Price' (using the variable fprice)
is the new price

I assumed you put in percentages for salestax and markup

like 5% sales tax and 20% markup

tax = storeprice * (1 + (taxrate/100) )
it just makes the % into a fraction and add one so it increases (so its x1.05 not x.05)

then
storeprice = originalprice * (1 + (markup/100) )
same reasoning

and new price = storeprice + tax

thats what I did in my program, and guido made syntax updates
__________________
chickendude is offline   Reply With Quote
Reply


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

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



All times are GMT -5. The time now is 03:32 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright FlashFlashRevolution