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