jane johnson

jane johnson

  • NA
  • 1
  • 2k

C++ help please

Nov 15 2012 2:35 AM
A parking garage charges a $2.00 minimum fee to park for up to three hours. The garage charges an  additional $0.50 per hour for each hour or part thereof in excess of three hours. The maximum charge for any given 24-hour period is $10.00.  People who park their cars for longer than 24 hours will pay $8.00  per day. 
first attempt: 
#include <iostream>
#include <string>
#include <stdlib.h>
int(HoursParked, string enterTime, string exitTime)
float parkingFee (Int hours);
string enterTime, exitTime;
cout <<"Please enter the date and time the car is entering "<< endl
<< "the parking garage in the following format: DD/MM/YY hh:mm"<< endl;
getline (cin, enterTime);
cout<< "Please enter the date and time the car is exiting "<< endl
<< "the parking garage in the following format: DD/MM/YY hh:mm"<< endl;
getline(cin, exitTime);
cout(feedue)<<fix<<set precision (2)<<
cout <<(HoursParked (enterTime, exitTime))enter
return 0;
int HoursParked (string)
int TotalDays=stringToInt (exitTime.subr(3,2))stringToInt(enterTime)
int TotalDays=stringToInt (exitTime.subr(9,2))stringToInt(enterTime)
int TotalDays=stringToInt (exitTime.subr(12,2))stringToInt(enterTime)
Hours=(TotalDays>0)? (TotalHours +24*TotalDays);
Hours=(TotalMins>0)? Total+1; TotalHours
if (Hours<=3)
else
{
second attempt: ( this on just tells you the amount for 3 or less hours, i dont know how to modiify it after that) #include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <sstream>
using namespace std;

stringstream ss;
string enter_date;
string enter_time;
string exit_date;
string exit_time;
int calculatecharge;
int num;
int i;
int year;
int month;
int ddmmyyChar;
int dayStr;
string line;
int x;
int hr;

void atk()
{
getline (cin,line);
stringstream ss1(line);
ss >> enter_date >> enter_time;
stringstream ss2(enter_date);
string year, month, day;
getline (ss2, year, '/');
}

int main()
{
cout << "Please enter the date and time the car is entering "<< endl
<< "the parking garage in the following format: YY/MM/DD hh:mm"<< endl;
atk();
cout << "Please enter the date and time the car is exiting "<< endl
<< "the parking garage in the following format: YY/MM/DD hh:mm"<< endl;
atk();
if (hr - hr < 3)
cout<<"Parking fee due: $2.00" << endl;
else (hr-hr >24)



Answers (1)