Whats wrong

This is one of my projects for college there is one error what is it??

Page 1 of 1

5 Replies - 488 Views - Last Post: 18 December 2008 - 07:46 PM Rate Topic: -----

#1 Daysaver  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 1
  • View blog
  • Posts: 36
  • Joined: 24-November 08

Whats wrong

Posted 18 December 2008 - 07:17 PM

#include <iostream>

using namespace std;

int main()

	{
	char fname[10]; //first name
	char sname[10]; //second name
	int age; // age of usr
	char ans; // anwnser to question
	int hours; // number of hours worked
	float income;
	


	 cout << "Working Tax Credit"<<endl;
	 
	 cout << "Could you plaese enter your first name."<<endl; // asks for usrs first name
	 
	 cin >> fname;
	 
	 cout << "Could you please enter your second name."<<endl; // asks for usrs secon name
	 
	 cin >> sname;
	 
	 cout << "hello " << fname<<endl;
	 
	 cout << "Could you please enter your age"<<endl; // asks for age
	 
	 cin >> age;
	 

	 if (age<25)
	 {
	 cout << "sorry ";
	 cout <<  fname;				 
	 cout << " ";
	 cout <<  sname;
	 cout <<  " but you may not continue you must be age 25 or over to be elagable for working tax credit"<<endl;
	 return 0; 
	 }
	  else
	 {
	 cout << "What is your living status?";
	 cout << "Please type y is you are living with someone or type n if you live alone";
	 cin >> ans;
	 }
	 if (ans='n')
	 {
	 cout << "how many hours do you work a week?";
	 cin >> hours;
	 }
	 if (hours>=30)
	 {
				   
	 cout << "You work more than 30 hours a week you are elagable for working tax credit";
	 }
	 else
	 {
	 cout << "sorry ";
	 cout <<  fname;				 
	 cout << " ";
	 cout <<  sname;
	 cout <<  " but you may not continue you must work over 30 hours a week to be elagable for working tax credit"<<endl;
	 return 0;
	 }
	 cout << "please enter your yearly income";
	 cin >> income;
	 if (income>=8612)
	 {
	 cout << "your are entitled to 1180";
	 }
	 if (income>=8612)
	 {
	 cout <<"your are entitled to 655";
	 
	 if (income>11701)						 
	 {
	 cout <<"sorry but you are not elagable for working tax credit";
	 return 0;										 
	 }
   
 
	 
   
	 















	 system("PAUSE");
	 return EXIT_SUCCESS;
}



Is This A Good Question/Topic? 0
  • +

Replies To: Whats wrong

#2 janotte  Icon User is offline

  • code > sword
  • member icon

Reputation: 990
  • View blog
  • Posts: 5,141
  • Joined: 28-September 06

Re: Whats wrong

Posted 18 December 2008 - 07:30 PM

What is the 'one error'?

Compiler error?
Runtime error?

Please give us a lead. Most people here are busy and don't have time to explore every possible error that might be in your code.
Was This Post Helpful? 0
  • +
  • -

#3 no2pencil  Icon User is offline

  • Toubabo Koomi
  • member icon

Reputation: 5191
  • View blog
  • Posts: 26,903
  • Joined: 10-May 07

Re: Whats wrong

Posted 18 December 2008 - 07:34 PM

If you properly indented your code, you would see that the conditional test if(income>=8612) does not have a closing bracket.
     if (income>=8612) {
       cout <<"your are entitled to 655";
     }
     if (income>11701) {
        cout <<"sorry but you are not elagable for working tax credit";
        return 0;
     }
     system("PAUSE");
     return EXIT_SUCCESS;
}



& just to add, while it doesn't cause the error, what is the difference between EXIT_SUCCESS & 0?
Was This Post Helpful? 0
  • +
  • -

#4 janotte  Icon User is offline

  • code > sword
  • member icon

Reputation: 990
  • View blog
  • Posts: 5,141
  • Joined: 28-September 06

Re: Whats wrong

Posted 18 December 2008 - 07:40 PM

View Postno2pencil, on 18 Dec, 2008 - 06:34 PM, said:

what is the difference between EXIT_SUCCESS & 0?


"EXIT_SUCCESS" is a macro supplied as part of standard C++ (since I think 1999?) that is considered 'more correct' than using 0.

Here's some more info:
http://www.cplusplus...IT_SUCCESS.html
Was This Post Helpful? 0
  • +
  • -

#5 no2pencil  Icon User is offline

  • Toubabo Koomi
  • member icon

Reputation: 5191
  • View blog
  • Posts: 26,903
  • Joined: 10-May 07

Re: Whats wrong

Posted 18 December 2008 - 07:43 PM

My point was using both of them looks silly.
Was This Post Helpful? 0
  • +
  • -

#6 janotte  Icon User is offline

  • code > sword
  • member icon

Reputation: 990
  • View blog
  • Posts: 5,141
  • Joined: 28-September 06

Re: Whats wrong

Posted 18 December 2008 - 07:46 PM

View Postno2pencil, on 18 Dec, 2008 - 06:43 PM, said:

My point was using both of them looks silly.


Oh yes - stupid me!!

Yes it is very silly to use both.
Pick one style option and stick to it.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1