hi im trying to read a txt file and could you please check what is wrong with this?
this is my code
// This program will calculate the charges for shipping
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdlib>
using std :: ifstream;
using namespace std;
int main()
{ // curly #1
char choice; //choices available in the main menu.
float weight; // Weight to be entered.
int weightcategory;
int shippingzone; // Shipping Zone to be selected.
int customeridno; // Customer ID Number.
int zone;
int charge;
cout << "Welcome to the DOWHILE FREIGHT ordering cart" << endl;
cout << "-------------MENU--------------" << endl;
cout << "1. To begin ordering enter '1'" << endl;
cout << "2. To quit enter '2'" << endl;
cout << "-------------------------------" << endl;
cout << "Choose an option (enter number):" << endl;
cin >> choice;
if(choice == '1')
{ // curly #2
customeridno = rand() * rand();
cout << "----------------------------------------" << endl;
cout << "Your Customer ID number is " << customeridno << endl;
cout << "----------------------------------------" << endl;
cout << "Please Enter the weight of your item" << endl; // Enter the weight of your item
cout << "We ship items between 1 to 60KG" << endl;
cin >> weight;
do
{ // curly #3
if(weight >= 1 && weight <= 60)
{ // curly #4
if (weight >= 1 && weight < 10)
weightcategory = 0;
else if (weight >= 10 && weight < 20)
weightcategory = 1;
else if (weight >= 20 && weight < 30)
weightcategory = 2;
else if (weight >= 30 && weight < 40)
weightcategory = 3;
else if (weight >= 40 && weight < 50)
weightcategory = 4;
else if (weight >= 50 && weight <= 60)
weightcategory = 5;
cout << "You have entered " <<weight<< "KG" << endl;
cout << "We are able to ship that amount of weight" << endl;
cout << "-----------------------------------------" << endl;
cout << "Please Enter the shipping number zone you would like to use" << endl;
cout << "We have 4 Shipping zones." << endl;
cout << "1. Standard Shipping. " << endl;
cout << "2. Special Standard Shipping." << endl;
cout << "3. Express Shipping." << endl;
cout << "4. Express Special Shipping." << endl;
cout << "-----------------------------------------" << endl;
cout << "Choose an Option (enter number):" << endl; // Select the Shipping Zone
cin >> shippingzone;
do
{ // curly #5
if (shippingzone >=1 && shippingzone <=4)
{ // curly #6
cout << "You have Selected Shipping Zone " << shippingzone << endl;
zone = shippingzone - 1;
ifstream.charge("shippingcharges.txt"); {
if(!charge) {
cout << "cannot open file" << endl;
return (1);
}
while (!charge.eof()&&(weightcategory<7)
charge >> shippingcharges [weightcategory][0];
}
charges.close();
} // curly 6
else
cout << "ERROR - Please enter one of the shipping zones shown above" << endl;
cin >> shippingzone;
} while (shippingzone >= 1 && shippingzone <= 4); // curly 5
} // curly #4
else
cout << "ERROR - Please Enter weight between 1 to 60KG" << endl;
cin >> weight;
} while (choice == '1'); // curly 3
} // curly #2
if (choice == '2')
{
exit (1);
}
else
cout << "ERROR - Please choose one of the following options" << endl;
cin >> choice;
system ("pause");
return 0;
} // curly #1
this is what i need help with
ifstream.charge("shippingcharges.txt"); {
if(!charge) {
cout << "cannot open file" << endl;
return (1);
}
while (!charge.eof()&&(weightcategory<7)
charge >> shippingcharges [weightcategory][0];
}
charges.close();
i got an error message saying
"expected primary-expression before '.' token"
could you please show me how to read txt files