Question
hello i am working on a c++ hw assignment and i keep getting these error messages when i run the program. maybe i been staring
hello i am working on a c++ hw assignment and i keep getting these error messages when i run the program. maybe i been staring at the screen to long but i was wondering if you can help me out.
These are the errors i keep getting:
main.cpp:143:1: error: cout does not name a type cout<<"Enter the date of last payment in the form of-dd/mm/yyyy:"; ^ main.cpp:144:1: error: cin does not name a type cin>>cust.dateOfLastPayment; ^ main.cpp:146:1: error: expected unqualified-id before return return cust; ^ main.cpp:148:1: error: expected declaration before } token }// end of getDetails function ^ main.cpp: In function int main(): main.cpp:110:17: warning: ignoring return value of int system(const char*), declared with attribute warn_unused_result [-Wunused-result] system("pause"); ^
Here is my code;
///////////////////
//program name: Customer Accounts
//program version: 1.0
// Alexander Martinez
// Date: 11/11/2017
///////////////////
#include
#include
#include
using namespace std;
/*Crate a structure DataOfCustomerAccount so that declares to store data of Customer
account.*/
/* structure declaration for data of Customer account */
struct DataOfCustomerAccount
{
// declare the required variables
string nameOfCustomer;
string addressOfCustomer;
string cityOfCustomer;
string stateOfCustomer;
int ZIP_Code;
double telephoneNumber;
double accountBalance;
string dateOfLastPayment;
}; // end of DataOfCustomerAccount structure
// function prototype
DataOfCustomerAccount getDetails(DataOfCustomerAccount &);
int getCustomer(DataOfCustomerAccount[],int,string);
void displayDetails(DataOfCustomerAccount[],int);
// start of main function
int main()
{
// declare a constant for maximum size of array
const int ARRAY_SIZE = 20;
//Decare an array of type DataOfCustomerAccount to store the details of all customers.
// declare an array of DataOfCustomerAccount
DataOfCustomerAccount customers[ARRAY_SIZE];
DataOfCustomerAccount customer;
// variable declaration
int userChoice;
int count = 0;
string fullName;
int modify;
/*repeat a loop until the user wants to exit the process of the value of customers count reaches 20 */
do
{
//Display the menu for user and prompts the user to enter the choice 1,2,3, and 4
// display the menu for the user
cout< cout<<"-------------Menu-----------------"< cout<<"1.Add the details of new customer"< cout<<"2.Change the details of a customer"< cout<<"3.Display the details of all customers"< cout<<"4.Exit"< cout<<"------------------------------"< //promt the user choice cout<<"Enter your choice (1/2/3/4):"; cin>> userChoice; //switch statement switch(userChoice) { case 1: /*call the getDetails method to get the details of a customer and store thee details in an array*/ /* call the getDetails method to get the details of a customer */ customers[count]=getDetails(customer); count++; break; case 2: /*Promt the user to enter full name of customer to be modified and call the getCustomer to get the customer number in the array and then modify the details of the customer except name if exist */ /*promt the user to enter the full name of customer to be modified*/ cout< cin>>fullName; /* call the getCustomer to get the number in the array */ modify= getCustomer(customers,count,fullName); if (modify==-1) cout< else { /*get the modified details of a customer */ customers[modify]=getDetails(customer); //reset the customer name if modified if (customers[modify].nameOfCustomer !=fullName) { cout< customers[modify].nameOfCustomer = fullName; }//end while }//end if-else break; case 3: // call the displayDetails method to display the details of the Customers /* call the displayDetails method to display the details of all customers */ displayDetails(customers,count); break; case 4: // close the process exit(0); default: //display an error message cout<<"Enter 1, 2, 3, or 4 only."< }//end switch }while(userChoice !=4 && count < ARRAY_SIZE); // pause the system for awhile system("pause"); return 0; }// end main function /*the following getDetails function prompts the user to enter the customer details as name, adress, city,state, ZIP, telephone number, account balance, and date of last payment.*/ //getDetails function definition DataOfCustomerAccount getDetails(DataOfCustomerAccount &cust) { // prompt the user to enter the name of customer cout< cout<<"Enter the name of customer:"; cin>>cust.nameOfCustomer; //prompt the user to enter the address of customer cout<<"Enter the address of customer:"; cin>>cust.addressOfCustomer; // prompt the user to enter the city of customer cout<<"Enter the city of customer:"; cin>>cust.cityOfCustomer; // prompt the user to enter the state of customer cout<<"Enter the state of customer:"; cin>>cust.stateOfCustomer; // prompt the user to enter the ZIP code cout<<"Enter the ZIP code of customer:"; cin>>cust.ZIP_Code; // prompt the user to enter the telephone number cout<<"Enter the phone number of customer:"; cin>>cust.telephoneNumber; // prompt the user to enter the account balance cout<<"Enter the account balance:$"; cin>>cust.accountBalance; }//end while // prompt the user to enter the date of last payment cout<<"Enter the date of last payment in the form of-dd/mm/yyyy:"; cin>>cust.dateOfLastPayment; return cust; }// end of getDetails function /*The following getDetails functions prompts the user to enter the customer details as name, adress,city,state,ZIP,telephone number,account balance, and date of last payment.*/ //getDetails function definition DataOfCustomerAccount getDetails(DataOfCustomerAccount &cust) { //prompt the user to enter the name of customer cout<<"Enter the name of customer:"; cin>>cust.nameOfCustomer; //prompt the user to enter the adress of customer cout<<"Enter the address of customer:"; cin>>cust.addressOfCustomer; // prompt the user to enter the city of customer cout<<"Enter the city of customer:"; cin>>cust.cityOfCustomer; //prompt the user to enter the state of customer cout<<"Enter the state of customer:"; cin>>cust.stateOfCustomer; //promt the user to enter the ZIP code of customer cout<<"Enter the ZIP code of customer:"; cin>>cust.ZIP_Code; //promt the user to enter the telephone number cout<<"Enter the telephone number of customer:"; cin>>cust.telephoneNumber; //prompt the user to enter the account balance cout<<"Enter the account balance of customer:$"; cin>>cust.accountBalance; /*varify whether the account balance is a negative value*/ while (cust.accountBalance<0) { cout<<"Enter the positive value:$"; cin>>cust.accountBalance; }//end while //promt the user to enter the date of last payment cout<<"Enter the date of last payment in form of-mm/dd/yyyy:"; cin>>cust.dateOfLastPayment; return cust; }//end the getDetails function /*The following getCustomer function varifies whether the customer name to be modified its details is in the array or not and returns the position of the customer in the array. Otherwise, returns -1.*/ //getCustomer function definition int getCustomer(DataOfCustomerAccount cust[],int size, string name) { int customer=-1; /*verify the customer name to be modified the details of the customer */ for(int i=0;i { if (cust[1].nameOfCustomer==name) { customer=i; break; }//end if }//end for return customer; }//end of getCustomer function /*The following displayDetails function displays the details of each customer as name, address, city,state, ZIP, telephone number, account balance, and date of last payment.*/ //displayDetails function definition void displayDetails (DataOfCustomerAccount cust [], int size) { /*verify whether the customer in the array is zero*/ if(size==0) cout< else { /*display the details of all customers in the array */ for(int i=0; { //display the name of customer cout< cout<<"The name of customer:"< //display the adress of customer cout<<"The address of customer:"< //display the city of customer cout<<"The city of customer:"< //display the state of customer cout<<"The state of customer:"< //display the ZIP code of customer cout<<"The ZIP code of customer:"< //display the telephone number of customer cout<<"The telephone number of customer:"< //display the account balance of customer cout<<"The account balance of customer:$"< //display the last payment date cout<<"The date of last payment:"< }//end for }//end if-else }//end of displayDetails function
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started