Good Evening. I am taking an intro c++ class. No one in the class appears to be on a mac and the book i have is using visual basic, i have spent hours just trying to figure out xcode and how to get into c++.
This is my program, nothing happens when i run it but i get no errors.
I think i saved payroll1.txt in the correct place, it is in xcode, right below the "groups and files" left pane
I checked file paths and they are both in the same file, is this correct? should it read from the file given where it is located?
/Users/malishka31/Documents/module22/Module2_3A.cpp
/Users/malishka31/Documents/module22/payroll1.txt
This is my program, nothing happens when i run it but i get no errors.
I think i saved payroll1.txt in the correct place, it is in xcode, right below the "groups and files" left pane
Code:
#include <iostream.h>
#include <iostream>
#include <fstream>
using namespace std;
int main (){
ifstream fin("payroll1.txt");
int employeeid, hoursworked, hourlyrate;
float grosspay;
cin>>employeeid>>hoursworked>>hourlyrate;
while(fin>>employeeid>>hoursworked>>hourlyrate){
grosspay=hoursworked*hourlyrate;
cout<< "The Employee ID is"<<employeeid<<"The Gross Pay is" << grosspay<<endl;
cin>>employeeid>>hoursworked>>hourlyrate;
}//While
fin.close();
}//Main
I checked file paths and they are both in the same file, is this correct? should it read from the file given where it is located?
/Users/malishka31/Documents/module22/Module2_3A.cpp
/Users/malishka31/Documents/module22/payroll1.txt
Last edited by a moderator: