final projet

need some advice

Page 1 of 1

4 Replies - 815 Views - Last Post: 20 November 2008 - 03:40 PM Rate Topic: -----

#1 wheelies  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 03-September 08

final projet

Posted 17 November 2008 - 09:31 AM

I wrote this program as an assignment and now I want to modify it for my final project so that it meets the criteria below. Any advice or help would be greatly appreciated. thanks in advance. rob

User interaction
At least 1 user-defined class (must instantiate object from class)
Contain all logic structures – sequence, selection and repetition
Read from or write to an external file
Operator overloading
Data-validation
At least one array (one-dimensional)
#include <iostream>
#include <string>
using namespace std;



int main ()
{
/* declare variables*/
	int date;
	string month;
	char goagain;

do
{
/* ask user for birth date information*/
cout << " Please press return after entering your information." << endl;
cout << "What is your birth date? Enter a month first, followed by date. " << endl;
cin >> month >> date;

/*beginning of 'if' statement
that determines your zodiac sign and then
displays the results to the screen*/

if ((month == "march" && date > 21) || (month == "april" && date < 19))
    cout << " You are Aries! Adventurous and energetic." << endl;
else if ((month == "april" && date > 20 ) || (month == "may" && date < 20))
	cout << "You are Taurus!Patient and reliable." << endl; 


if (month == "march" && date == 21)
{   cout <<  " You are Aries! Adventurous and energetic. You are on the cusp" <<endl;
	cout << " of pisces, who is Imaginative and sensitive." << endl;
}
else if (month == "april" && date == 19)
{	     cout <<  " You are Aries! Adventurous and energetic. You are on the cusp" << endl;
	     cout <<"of Taurus, Who is Patient and reliable." << endl;
}

if     (month == "march" && date == 20)
{   	cout << "You are Pisces!Imaginative and sensitive. You are on the cusp" << endl;
		cout << "of Aries! Who is Adventurous and energetic." << endl;
}
else if (month == "april" && date == 20)
{	cout << "You are Taurus!Patient and reliable. You are on the cusp " <<  endl;
	cout << "of Aries! Who is Adventurous and energetic." << endl;
}

if ((month == "may" && date > 21) || (month == "june" && date < 22))
	cout << "You are Gemini! Adaptable and versatile." << endl;
else if ((month == "june" && date > 22 ) || (month == "july" && date < 22))
	cout << "You are Cancer! Emotional and loving." << endl;

if (month == "may" && date == 21)
{	cout << "You are Gemini! Who is Adaptable and versatile. You are on the cusp" << endl;
	cout << "of Taurus, who is Patient and reliable." << endl;
}

else if (month == "june" && date ==22)
{	cout << "You are Cancer! Emotional and loving. You are on the cusp" << endl;
	cout << "of  Gemini, who is adaptable and versatile." << endl;
}
if (month =="may" && date == 20)
{	cout << "You are Taurus!Patient and reliable. You are on the cusp " <<  endl;
	cout << "of Gemini! Who is Adaptable and versatile." << endl;
}
else if (month == "june" && date ==21)
{	cout << "You are Gemini! Adaptable and versatile.You are on the cusp" << endl;
	cout << "of Cancer! Emotional and loving." << endl;
}
if ((month == "july" && date < 22)|| (month == "august" && date < 22))
	cout << "You are Leo! Generous and warmhearted." << endl;
else if ((month == "august" && date > 23 ) || (month == "september" && date < 21))
	cout << "You are Virgo! Modest and shy." << endl;

if (month == "july" && date == 23)
{	cout << "You are Leo! Generous and warmhearted.You are on the cusp" << endl;
	cout << "of Cancer! Emotional and loving." << endl;
}
else if  (month == "august" && date == 22)
{	cout << "You are Leo! Generous and warmhearted. You are on the cusp" << endl;
	cout << "of Virgo, Who is modest and shy." << endl;
}
if (month == "july" && date == 22)
{	cout << "You are Cancer! Emotional and loving. You are on the cusp" << endl;
	cout << "of Leo! Generous and warmhearted." << endl;
}
else if  (month == "august" && date == 23)
{	cout << "You are Virgo! Modest and shy.You are on the cusp" << endl;
	cout << "of Leo! Generous and warmhearted." << endl;
}
if ((month == "september" && date > 23) || (month == "october" && date < 22))
	cout << "You are Libra! Diplomaitic and urbane." << endl;
else if ((month == "october" && date < 22) || (month == "november" && date < 21))
	cout << "You are Scorpio! Determined and forceful." << endl;

if (month == "september" && date == 23)
{	cout << "You are Libra! Diplomaitic and urbane. You are on the cusp" << endl;
	cout << "of Virgo! who is modest and shy." << endl;
}
else if(month == "october" && date == 22)
{	cout << "You are Libra! Diplomaitic and urbane. You are on the cusp" << endl;
	cout << "of Scorpio, Who is determined and forceful." << endl;
}

 if(month == "october" && date == 23)
{	cout << "You are Scorpio! Determined and forceful. You are on the cusp" << endl;
	cout << "of Libra! Diplomaitic and urbane." << endl;
}
else if (month == "september" && date == 22)
{	cout << "You are Virgo! Modest and shy.You are on the cusp" << endl;
	cout << "of Libra! Diplomaitic and urbane." << endl;
 }

if ((month == "november" && date < 21) || (month == "december" && date < 22))
	cout << "You are Sagittarius! Optimistic and freedom-loving." << endl;
else if ((month == "december" && date > 22) || (month == "january" && date < 19))
	cout << "You are Capricorn! Practical and prudent." << endl;

if (month == "november" && date == 22)
{	cout << " You are Sagittarius! Optimistic and freedom-loving. You are on the cusp" << endl;
	cout << "of Scorpio, who is determined and forceful" << endl;
}
else if (month == "december" && date == 21)
{	cout << "You are Sagittarius! Optimistic and freedom-loving. You are on the cusp" << endl;
	cout << "of Capricorn, who is Practical and prudent" << endl;
}
if (month == "december" && date == 22) 
{	cout << "You are Capricorn! Practical and prudent. You are on the cusp" << endl;
	cout << "of Sagittarius, who is Optimistic and freedom-loving." << endl;
}
else if (month == "november" && date == 21)
{		cout << "You are Scorpio! Determined and forceful. You are on the cusp" << endl;
		cout << "of Sagittarius, who is Optimistic and freedom-loving." << endl;
}
if ((month == "january" && date > 20) || (month == "february" && date < 18))
	cout << "You are Aquarius! Friendly and humanitarian." << endl;
else if ((month == "february" && date > 19) || (month == "march" && date < 20))
    cout << "You are Pisces! Imaginative and sensitive." << endl;

if  (month == "january" && date == 20)
{	cout << "You are Aquarius! Friendly and humanitarian. You are on the cusp" << endl;
	cout << "of Capricorn, who is Practical and prudent." << endl;
}
else if (month == "february" && date == 18)
{	cout << "You are Aquarius! Friendly and humanitarian. You are on the cusp" << endl;
    cout << "of Pisces who is Imaginative and sensitive" << endl;
}
if (month == "february" && date ==19)
{	cout << "You are Pisces!Imaginative and sensitive. You are on the cusp" << endl;
	cout << "of Aquarius, who is Friendly and humanitarian." << endl;
}
else if (month == "january" && date == 19)
{	    cout << "You are Capricorn! Practical and prudent. You are on the cusp" << endl;
		cout << "of Aquarius, who is Friendly and humanitarian." << endl; 
}

/*asks the user if they want to play again*/
cout << "would you like to go again? Please enter y or n" << endl;
cin  >> goagain;

/*states that upper or lower case y means go again*/
}while  ( goagain =='y' || goagain == 'Y');

system ("pause");

return 0;
}



** Edit ** :code:

Is This A Good Question/Topic? 0
  • +

Replies To: final projet

#2 Gloin  Icon User is offline

  • Expert Schmexpert...
  • member icon

Reputation: 235
  • View blog
  • Posts: 4,489
  • Joined: 04-August 08

Re: final projet

Posted 17 November 2008 - 10:15 AM

[rules][/rules]


You could for example use an array to store the message of a zodiac-sign and calculate indexes using some conversion algorithm. Actually, using several arrays of different types will makes this program much easier to write..
Was This Post Helpful? 0
  • +
  • -

#3 wheelies  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 03-September 08

Re: final projet

Posted 19 November 2008 - 10:12 PM

View PostGloin, on 17 Nov, 2008 - 09:15 AM, said:

[rules][/rules]


You could for example use an array to store the message of a zodiac-sign and calculate indexes using some conversion algorithm. Actually, using several arrays of different types will makes this program much easier to write..



ok heres what i got so far. I have alot of stuff commented. The array commented on the bottom looks good to me, but I just dont know where to put it or how to use it. the program is working right now. I have the "data validation" requirement fulfilled. if you read my comments on top i am clear on what i yet need to do , but unclear as how to do it. Ijust need to meet the basic requirements of this project. I will never be a programmer nor do I want to be. I am actually 5 weeks away from finishing an electronics repair degree. why this is even required for my program of study is crazy to me. any help is appreiated
thanks rob








  /*rob klibenski
created 10/19/08
modified 9/20/08--9/21/08--9/23/08--9/22/08--10/01/08--10/08/08--10/09/08--11/12/08--11/13/08--
		 11/14/08--11/15/08--11/16/08--11/17/08--11/17/08--11/19/08(Chris Hall)
description: astrology program final project pg 174 #3
*/

/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  To-Do List:
		-Save Zodiac Discriptions to external file (zodiac.txt)
		-Load the .txt file
		-read the discriptions to an array (string zodiacDisc[])
		-ask the user for his/her name
		-make a class (mySign) to hold the user's name, birthdate, and zodiac sign
		-set outputs to include the users name and birthdate in addition to their sign
		-overload operator<< to accept the data type of the class and output the relavent data.
		
  Suggested Changes:
			+change the month from string type to int type and use numbers for easier checking
			+add checking for months with less than 31 days (i.e. February)
			+add code to allow the user to input their birthdate in a more common format (MM/DD)
				 this code will look something like:
					  cin.getline(int,cin,'/') >> month >> day;
			
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/




#include <fstream>
#include <iostream>
#include <string>
using namespace std;
void outputnumber(ifstream);



int main ()
{
// declare variables
	//int number;
	//ofstream outfile;
	int date;
	string month;
	char goagain;
	//outfile.open("text.txt");
	//outfile.close();
	//int months []={1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
	//string name{months};
	//int i;

do
{
	

		// ask user for birth date information
		cout << " Please press return after entering your information." << endl;
		cout << "What is your birth date? Enter a month first, followed by date. " << endl;
		cout << "Please use lower case for the month and numbers for the date." << endl;
		cin >> month >> date;
		
		
		// if statement that ensures proper info is entered
		if (month != "january" && month != "february" && month != "march" && month != "april" && month != "may" && month != "june" && month != "july" && month != "august" && month != "september" && month != "october" && month != "november" && month != "december")
			{
				  cout << "Please enter correct spelling for month or use lower case letters." << endl;
				  goagain = 'y';
				  //system pause
				  system ("pause");
			}
		if (date <= 0 || date > 31)
			{
				cout << "Check that you have entered a valid date between 1-31" << endl;
				goagain = 'y';
				//system pause
				system ("pause");
			}
	 
/*beginning of 'if' statement
that determines your zodiac sign and then
displays the results to the screen*/

if ((month == "march" && date > 21) || (month == "april" && date < 19))
	cout << " You are Aries! Adventurous and energetic." << endl;
else if ((month == "april" && date > 20 ) || (month == "may" && date < 20))
	cout << "You are Taurus!Patient and reliable." << endl; 


if (month == "march" && date == 21)
{   cout <<  " You are Aries! Adventurous and energetic. You are on the cusp" <<endl;
	cout << " of pisces, who is Imaginative and sensitive." << endl;
}
else if (month == "april" && date == 19)
{		 cout <<  " You are Aries! Adventurous and energetic. You are on the cusp" << endl;
		 cout <<"of Taurus, Who is Patient and reliable." << endl;
}

if	 (month == "march" && date == 20)
{   	cout << "You are Pisces!Imaginative and sensitive. You are on the cusp" << endl;
		cout << "of Aries! Who is Adventurous and energetic." << endl;
}
else if (month == "april" && date == 20)
{	cout << "You are Taurus!Patient and reliable. You are on the cusp " <<  endl;
	cout << "of Aries! Who is Adventurous and energetic." << endl;
}

if ((month == "may" && date > 21) || (month == "june" && date < 22))
	{cout << "You are Gemini! Adaptable and versatile." << endl;}
else if ((month == "june" && date > 22 ) || (month == "july" && date < 22))
	{cout << "You are Cancer! Emotional and loving." << endl;}

if (month == "may" && date == 21)
{	cout << "You are Gemini! Who is Adaptable and versatile. You are on the cusp" << endl;
	cout << "of Taurus, who is Patient and reliable." << endl;
}

else if (month == "june" && date ==22)
{	cout << "You are Cancer! Emotional and loving. You are on the cusp" << endl;
	cout << "of  Gemini, who is adaptable and versatile." << endl;
}
if (month =="may" && date == 20)
{	cout << "You are Taurus!Patient and reliable. You are on the cusp " <<  endl;
	cout << "of Gemini! Who is Adaptable and versatile." << endl;
}
else if (month == "june" && date ==21)
{	cout << "You are Gemini! Adaptable and versatile.You are on the cusp" << endl;
	cout << "of Cancer! Emotional and loving." << endl;
}
if ((month == "july" && date < 22)|| (month == "august" && date < 22))
	{cout << "You are Leo! Generous and warmhearted." << endl;}
else if ((month == "august" && date > 23 ) || (month == "september" && date < 21))
	{cout << "You are Virgo! Modest and shy." << endl;}

if (month == "july" && date == 23)
{	cout << "You are Leo! Generous and warmhearted.You are on the cusp" << endl;
	cout << "of Cancer! Emotional and loving." << endl;
}
else if  (month == "august" && date == 22)
{	cout << "You are Leo! Generous and warmhearted. You are on the cusp" << endl;
	cout << "of Virgo, Who is modest and shy." << endl;
}
if (month == "july" && date == 22)
{	cout << "You are Cancer! Emotional and loving. You are on the cusp" << endl;
	cout << "of Leo! Generous and warmhearted." << endl;
}
else if  (month == "august" && date == 23)
{	cout << "You are Virgo! Modest and shy.You are on the cusp" << endl;
	cout << "of Leo! Generous and warmhearted." << endl;
}
if ((month == "september" && date > 23) || (month == "october" && date < 22))
	cout << "You are Libra! Diplomaitic and urbane." << endl;
else if ((month == "october" && date < 22) || (month == "november" && date < 21))
	cout << "You are Scorpio! Determined and forceful." << endl;

if (month == "september" && date == 23)
{	cout << "You are Libra! Diplomaitic and urbane. You are on the cusp" << endl;
	cout << "of Virgo! who is modest and shy." << endl;
}
else if(month == "october" && date == 22)
{	cout << "You are Libra! Diplomaitic and urbane. You are on the cusp" << endl;
	cout << "of Scorpio, Who is determined and forceful." << endl;
}

 if(month == "october" && date == 23)
{	cout << "You are Scorpio! Determined and forceful. You are on the cusp" << endl;
	cout << "of Libra! Diplomaitic and urbane." << endl;
}
else if (month == "september" && date == 22)
{	cout << "You are Virgo! Modest and shy.You are on the cusp" << endl;
	cout << "of Libra! Diplomaitic and urbane." << endl;
 }

if ((month == "november" && date < 21) || (month == "december" && date < 22))
	cout << "You are Sagittarius! Optimistic and freedom-loving." << endl;
else if ((month == "december" && date > 22) || (month == "january" && date < 19))
	cout << "You are Capricorn! Practical and prudent." << endl;

if (month == "november" && date == 22)
{	cout << " You are Sagittarius! Optimistic and freedom-loving. You are on the cusp" << endl;
	cout << "of Scorpio, who is determined and forceful" << endl;
}
else if (month == "december" && date == 21)
{	cout << "You are Sagittarius! Optimistic and freedom-loving. You are on the cusp" << endl;
	cout << "of Capricorn, who is Practical and prudent" << endl;
}
if (month == "december" && date == 22) 
{	cout << "You are Capricorn! Practical and prudent. You are on the cusp" << endl;
	cout << "of Sagittarius, who is Optimistic and freedom-loving." << endl;
}
else if (month == "november" && date == 21)
{		cout << "You are Scorpio! Determined and forceful. You are on the cusp" << endl;
		cout << "of Sagittarius, who is Optimistic and freedom-loving." << endl;
}
if ((month == "january" && date > 20) || (month == "february" && date < 18))
	{cout << "You are Aquarius! Friendly and humanitarian." << endl;}
else if ((month == "february" && date > 19) || (month == "march" && date < 20))
	{cout << "You are Pisces! Imaginative and sensitive." << endl;}

if  (month == "january" && date == 20)
{	cout << "You are Aquarius! Friendly and humanitarian. You are on the cusp" << endl;
	cout << "of Capricorn, who is Practical and prudent." << endl;
}
else if (month == "february" && date == 18)
{	cout << "You are Aquarius! Friendly and humanitarian. You are on the cusp" << endl;
	cout << "of Pisces who is Imaginative and sensitive" << endl;
}
if (month == "february" && date ==19)
{	cout << "You are Pisces!Imaginative and sensitive. You are on the cusp" << endl;
	cout << "of Aquarius, who is Friendly and humanitarian." << endl;
}
else if (month == "january" && date == 19)
{		cout << "You are Capricorn! Practical and prudent. You are on the cusp" << endl;
		cout << "of Aquarius, who is Friendly and humanitarian." << endl; 
}


//asks the user if they want to play again. loop sequence
cout << "\nwould you like to go again? Please enter y or n" << endl;
cin  >> goagain;

//clear the screen
system("cls");
//states that upper or lower case y means go again
}while  ( goagain =='y' || goagain == 'Y');


return 0;
}

/*array?
month[0] ="january";
month[1] ="february";
month[2] ="march";
month[3] ="april";
month[4] ="may";
month[5] ="june";
month[6] ="july";
month[7] ="august";
month[8] ="september";
month[9] ="october";
month[10] ="november";
month[11] ="december";
for (i=0; i<month; i++)
cout <<month[i],,":"<<date[i]<< "";


//overloaded operator?
ostream &operator<< (ostream &output,const date&)
{static char *monthname[12} = {"january", "february", "march", "april", "may", 
								"june", "july", "august", "september", "october",
								"november", "december"};

output << monthname[.month]<< "" << day<< "" << year <<"" << endl;*/
  

Was This Post Helpful? 0
  • +
  • -

#4 wheelies  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 03-September 08

Re: final projet

Posted 20 November 2008 - 02:41 PM

thanks for nothing
Was This Post Helpful? 0
  • +
  • -

#5 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6064
  • View blog
  • Posts: 23,520
  • Joined: 23-August 08

Re: final projet

Posted 20 November 2008 - 03:40 PM

Well, I'm guessing your professor added these comments to your original program:
/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

  To-Do List:
		-Save Zodiac Discriptions to external file (zodiac.txt)
		-Load the .txt file
		-read the discriptions to an array (string zodiacDisc[])
		-ask the user for his/her name
		-make a class (mySign) to hold the user's name, birthdate, and zodiac sign
		-set outputs to include the users name and birthdate in addition to their sign
		-overload operator<< to accept the data type of the class and output the relavent data.
		
  Suggested Changes:
			+change the month from string type to int type and use numbers for easier checking
			+add checking for months with less than 31 days (i.e. February)
			+add code to allow the user to input their birthdate in a more common format (MM/DD)
				 this code will look something like:
					  cin.getline(int,cin,'/') >> month >> day;
			
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/


Sounds like he/she has told you exactly what you need to do, so now you need to apply that which you've learned in the class (you did go to class, right?) and do it. Sorry we didn't snap to and do your work for you.

Honestly, we don't care if you don't think you'll ever use it again, but it's required for you to graduate. We have all had to take classes we don't like, and the intellectually honest people make their best effort to do the required work no matter how much we may loathe it.

This post has been edited by JackOfAllTrades: 20 November 2008 - 03:41 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1