receipt help with loops and strings

im trying to read from the file that has five items included in it, and if it has less than 5 items it will display an error as well show the tax and see if t its taxable or e to exempt and im suppose to display a receipt using strings and space the receipt using padleft and padRight but im stuck any help would be appreciated this is what I have so far
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
  #include<iostream>
#include<fstream>
#include<iomanip>
#include <sstream>
using namespace std;

string padLeft(string,char,int);
string padRight(string,char,int);
string fromMoneyToStr(double);
int main()
{
  int tax=0;
  string item1,item2,item3,item4,item5;
  double price1,price2,price3,price4,price5;
  char a,b,c,d,e;
  string f,g,h,i,j;

  ifstream inFile;
  inFile.open("input.dat");

  if(inFile.fail())
    {
      cout<<"The file failed to open."<<endl;
      return -1;
    }
  inFile>> tax >> item1 >> price1 >> a >> item2 >> price2 >> b >> item3 >>\
 price3 >> c >> item4 >> price4 >> d >> item5 >> price5 >> e;

  inFile.close();

  f=fromMoneyToStr(price1);
  g=fromMoneyToStr(price2);
  h=fromMoneyToStr(price3);
  i=fromMoneyToStr(price4);
  j=fromMoneyToStr(price5);

  cout<< f << " " << g << " " << h << " " << i << " " <<j <<endl;

  return 0;
}
Last edited on
using strings and space the receipt using padleft and padRight but im stuck any help would be appreciated this is what I have so far

Where are you stuck? Explain your issue.
first problem is when I try calling the items from the file it displays this 4.87049e-270 1.16458e-307 4.86247e-270 2.12203e-314 2.18846e-314 and that now right as well I don't understand how to get the padleft and padright to displa the receipt as well how to add the functions to get the sales tax and grand total
Last edited on
this is whats in the file
2.3
movie ticket 20.00 T
water 2.25 T
popcorn 5.00 E
hotdog 15.00 T
candy 3.50 E
Last edited on
Topic archived. No new replies allowed.