Thread: C++ Help
View Single Post
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: 35
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