| ft95 (27) | |
|
I want this: car hour charge 1 1.5 2.00 2 4.0 2.50 3 24.0 10 but I don't know what should I do!!!! #include "stdafx.h" #include<iostream> #include<iomanip> using namespace std; void calculateCharge(double,int); int _tmain(int argc, _TCHAR* argv[]) { double hours; int i; cout<<setw(10)<<"Enter hours:\n"; cout<<"car"<<setw(10)<<"hours"<<setw(10)<<"charge\n"; cout<<setw(25); cin>>hours; for(i=1;i<=3;i++) { calculateCharge(hours,i); cout<<setw(25); cin>>hours; } } void calculateCharge(double hours,int i) { int x; double charge; cout<<i<<setw(10)<<hours<<setw(10); if(hours<3&&hours>0) { cout<<"2.00"; } else if(hours==24) { cout<<"10.00"; } else { x=ceil(hours)-3; charge=x*0.5; cout<<charge+2; } } | |
|
Last edited on
|
|
| methodos (52) | |
|
What is exactly the output you get here? I don't see any endlines. So if you want the table to display correctly you at least have to seperate the lines in your for loop.like: cout << endl;By the way:You can use the code blocks when you write a post by clicking the <> button next to the window you write in. Makes it more easy for all of us. | |
|
Last edited on
|
|
| ft95 (27) | |
|
ok,thank you so much. I solved my problem | |
|
|
|