4 Replies - 354 Views - Last Post: 03 April 2009 - 08:26 PM Rate Topic: -----

#1 *Pali*  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 04-February 09

can anyone tell me wuts wrong with this!

Post icon  Posted 03 April 2009 - 07:39 PM

A= accept the card and ask for adress
T= address and tell them if accept and trnsfer the balance
D= decline the card


Potentials file =X Joe Scholtz 437-4798
A Tim Wade 768-7658
X Sara Jobs 326-7857
! Jaynce Bee 354-8678



#include <iostream>
#include <fstream>
#include <cstdlib>
// This program reads values from the file 'Potentials.txt'
using namespace std;
int main()
{
	char status;
	char fname[20];
	char lname[20];
	char phonenumber[20];
	char address[40];
	char choice;
	int amount;
	
   ifstream inFile;
   ofstream outputFile;
   outputFile.open("Confirmed.txt");
   inFile.open("Potentials.txt");

   while(!inFile.eof())
   {
   inFile>> status;
   inFile >> fname;
   inFile>> lname;
   inFile>> phonenumber;
   
   cout << fname << " " << lname << endl;
   cout << phonenumber << endl;
   if (status=='X')
	  cout << " Preferred customer gets a rate of 7.9%" << endl; 
   else
	  cout << " Not Preferred customer gets a rate of 12.9%"<< endl;
   cout << " (A) accept/n";
   cout << " (T) transfer amount/n";
   cout << " {D} decline/n"; 
   cin >> choice;
   cin.ignore();
	  
   switch(choice)
   {
				 case 'A':
					  case 'a':
						   cout << " Enter an address";
						  
						   cout << " Thank you expect the card soon";
						   cin >> address;
						   
							  
				 outputFile << fname << " " << lname << endl;
				 outputFile << address << endle;
				 outputFile << status << " " << choice << endl;
				 break;
					  
   
   
				 case 'T':
					  case 't':
						   if (status=='X')
						   {
						   cout << " There's no transfer limit";
						   cin >> amount;
						   }
						   else
						   {
							   cout << " Enter amount less than 1000";
							   cin >> amount;
							   cin.ignore();
						   while (amount <1000)
						   {
								 cout << " Enter amount again ";
								 cin >> amount;
								 cin.ignore();
						   }
   }
						   {
						   cout << " Enter address ";
						   cin.getline(address [41])
						   cout << address << " " << your money has been transfered << endl;
   
				outputFile << fname << " " << lname << endl;
				outputFile << address << endle;
				outputFile << status << " " << choice << endl;
				break;
				
				case 'D':
					 case 'd':
						  if (status=='X')
						  {
						  cout << " You got cash back reward, Please call 1-800-CASHREWARD ";
						  }
						  else
						  {
							  cout <<" Thank you ";
							  }
							  break;
							  }
 inFile.close();
 outputFile.close();

	
	system("PAUSE");
	return EXIT_SUCCESS;
}


Is This A Good Question/Topic? 0
  • +

Replies To: can anyone tell me wuts wrong with this!

#2 n8wxs  Icon User is offline

  • --... ...-- -.. . -. ---.. .-- -..- ...
  • member icon

Reputation: 972
  • View blog
  • Posts: 3,878
  • Joined: 07-January 08

Re: can anyone tell me wuts wrong with this!

Posted 03 April 2009 - 07:49 PM

What error(s) are you having?
Was This Post Helpful? 0
  • +
  • -

#3 *Pali*  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 04-February 09

Re: can anyone tell me wuts wrong with this!

Posted 03 April 2009 - 07:55 PM

#include <iostream>
#include <fstream>
#include <cstdlib>
// This program reads values from the file 'Potentials.txt'
using namespace std;
int main()
{
    char status;
    char fname[20];
    char lname[20];
    char phonenumber[20];
    char address[40];
    char choice;
    int amount;
    
   ifstream inFile;
   ofstream outputFile;
   outputFile.open("Confirmed.txt");
   inFile.open("Potentials.txt");

   while(!inFile.eof())
   {
   inFile>> status;
   inFile >> fname;
   inFile>> lname;
   inFile>> phonenumber;
   
   cout << fname << " " << lname << endl;
   cout << phonenumber << endl;
   if (status=='X')
      cout << " Preferred customer gets a rate of 7.9%" << endl; 
   else
      cout << " Not Preferred customer gets a rate of 12.9%"<< endl;
   cout << " (A) accept/n";
   cout << " (T) transfer amount/n";
   cout << " {D} decline/n"; 
   cin >> choice;
   cin.ignore();
      
   switch(choice)
   {
                 case 'A':
                      case 'a':
                           cout << " Enter an address";
                          
                           cout << " Thank you expect the card soon";
                           cin >> address;
                           
                              
                 outputFile << fname << " " << lname << endl;
                 [color="#FF0000"]outputFile << address << endle;[/color]
                 outputFile << status << " " << choice << endl;
                 break;
                      
   
   
                 case 'T':
                      case 't':
                           if (status=='X')
                           {
                           cout << " There's no transfer limit";
                           cin >> amount;
                           }
                           else
                           {
                               cout << " Enter amount less than 1000";
                               cin >> amount;
                               cin.ignore();
                           while (amount <1000)
                           {
                                 cout << " Enter amount again ";
                                 cin >> amount;
                                 cin.ignore();
                           }
   }
                           {
                           cout << " Enter address ";
                           [color="#FF0000"]cin.getline(address [41])[/color]
                           cout << address << " " << your money has been transfered << endl;
   
                outputFile << fname << " " << lname << endl;
                [color="#FF0000"]outputFile << address << endle;[/color]
                outputFile << status << " " << choice << endl;
                break;
                
                case 'D':
                     case 'd':
                          if (status=='X')
                          {
                          cout << " You got cash back reward, Please call 1-800-CASHREWARD ";
                          }
                          else
                          {
                              cout <<" Thank you ";
                              }
                              break;
                              }
 inFile.close();
 outputFile.close();

    
    system("PAUSE");
    return EXIT_SUCCESS;
}



and it keeps telling me that the address is not declared[b]
Was This Post Helpful? 0
  • +
  • -

#4 FrozenSnake  Icon User is offline

  • En man från Sverige!

Reputation: 122
  • View blog
  • Posts: 995
  • Joined: 30-July 08

Re: can anyone tell me wuts wrong with this!

Posted 03 April 2009 - 08:09 PM

You should read the error messages.
They are there for a reason!
And make sure you end a line with ; you have forgot one somewhere!

For ex. you have this line now
cout << address << " " << your money has been transfered << endl;


It should be
cout << address << " your money has been transfered" << endl;


And you should indent "correctly" it will make it easier to read the code and you will see that some } are missing.

						   if (status=='X')
						   {
						   cout << " There's no transfer limit";
						   cin >> amount;
						   }
						   else
						   {
							   cout << " Enter amount less than 1000";
							   cin >> amount;
							   cin.ignore();
						   while (amount <1000)
						   {
								 cout << " Enter amount again ";
								 cin >> amount;
								 cin.ignore();
						   }
   }

the last } look like it doesn't belong to the else but it do. you have forgot a few of them too, and check your spelling on keywords.
on some places you have written endle.

Also read this
http://www.cplusplus...am/getline.html

This is your code (only indented so you will see better) I got your code to work so if you read the error messages you can fix it. It's simple.
#include <iostream>
#include <fstream>
#include <cstdlib>
// This program reads values from the file 'Potentials.txt'
using namespace std;
int main()
{
	char status;
	char fname[20];
	char lname[20];
	char phonenumber[20];
	char address[40];
	char choice;
	int amount;

	ifstream inFile;
	ofstream outputFile;
	outputFile.open("Confirmed.txt");
	inFile.open("Potentials.txt");

	while(!inFile.eof())
	{
		inFile>> status;
		inFile >> fname;
		inFile>> lname;
		inFile>> phonenumber;

		cout << fname << " " << lname << endl;
		cout << phonenumber << endl;
		if (status=='X')
			cout << " Preferred customer gets a rate of 7.9%" << endl;
		else
			cout << " Not Preferred customer gets a rate of 12.9%"<< endl;

		cout << " (A) accept/n";
		cout << " (T) transfer amount/n";
		cout << " {D} decline/n";
		cin >> choice;
		cin.ignore();

		switch(choice)
		{
			case 'A':
			case 'a':
				cout << " Enter an address";

				cout << " Thank you expect the card soon";
				cin >> address;

				outputFile << fname << " " << lname << endl;
				outputFile << address << endle;
				outputFile << status << " " << choice << endl;
				break;

			case 'T':
			case 't':
				if (status=='X')
				{
					cout << " There's no transfer limit";
					cin >> amount;
				}
				else
				{
					cout << " Enter amount less than 1000";
					cin >> amount;
					cin.ignore();
					while (amount <1000)
					{
						cout << " Enter amount again ";
						cin >> amount;
						cin.ignore();
					}
				}
				{ // what is this? And where is it suppose to be closed
					cout << " Enter address ";
					cin.getline(address [41])
					cout << address << " " << your money has been transfered << endl;

					outputFile << fname << " " << lname << endl;
					outputFile << address << endle;
					outputFile << status << " " << choice << endl;
					break;

			case 'D':
			case 'd':
				if (status=='X')
				{
					cout << " You got cash back reward, Please call 1-800-CASHREWARD ";
				}
				else
				{
					cout <<" Thank you ";
				}
				break;
				
				} // This one closes the one on line 74. 
			inFile.close();
			outputFile.close();


			system("PAUSE");
			return EXIT_SUCCESS;
		} // This close the switch now you need to fix the rest, so as you can see you have forgot some of the } 


This post has been edited by FrozenSnake: 03 April 2009 - 08:15 PM

Was This Post Helpful? 1
  • +
  • -

#5 *Pali*  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 21
  • Joined: 04-February 09

Re: can anyone tell me wuts wrong with this!

Posted 03 April 2009 - 08:26 PM

thanks
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1